actionscript 2.0学习手册

二 16 2005

心得

  • Actionscript是基于ECMAscript开发的。
  • Actionscript只是OOP的一种实现方法。
  • 所谓的OOP,就是虚拟了一个环境、环境中的物体、物体的属性、物体间的关系,这是一个初步的设定,然后可以根据这些基本的形态设定来尽兴扩展、删减(?)。这是世界的特征。
  • a class is the template from which an object is made:class是创建object的template。
  • The term instance is often used as a synonym for object… Creating a new object from a class is sometimes called instantiation.
  • Encapsulation 封装。通过对var的属性的控制(public或者private),封装可以保证在一个程序中相对独立的空间,从而一方面保护了开发的独立性(比如团队协作或同一程序的不同模块),另一方面可以进行整合前的独立测试。
  • Each class in an object-oriented program can be thought of as defining a unique kind of data, which is formally represented as a datatype in the program. Class是datatype。
  • Subclass inherit superclass, we call that is “inheritance”.
  • packages are directories that are collections of class files (i.e., collections of .as files). Packages是class的集合。
  • But not all Flash applications need to be purely object-oriented.
  • “Timeline-based development usually goes hand-in-hand with procedural programming
    because you want to take certain actions at the time a particular frame is reached. In Flash, “procedural programming” means executing code, defining functions, and setting variables on frames in a document’s timeline or on graphical components on stage.”
    这便是我以前在不知晓任何编程系统知识的情况下,在flash中进行的“结构化编程”:通过将自己的要求模块化,然后将他们分布在timeline和btn上,由timeline和btn所包含的命令来控制程序流程。在这种结构化的编程中,除了流程的不便于维护、更新、改变以外,思路的混乱、条件的缺失是经常发生的事情。
  • Flash’s ability to combine procedural and object-oriented code in a graphical, time-based development environment makes it uniquely flexible. That flexibility is both powerful and dangerous.
    flash可以将面对对象的编程和结构化编程结合在一起,使得编程变得非常强大而且灵活,但是这种灵活也是非常危险的。
    Ultimately, the amount of OOP you end up using in your work is a personal decision that will vary according to your experience and project requirements.
    根本上来说,OOP的使用数量是一个个人数量,这基于你的经验和项目需求。
    Ultimately, if the software works and can be maintained, you’re doing something right.
    根本上来说,只要软件工作好并且好维护,那么就去作正确的事情。
  • Every value in ActionScript 2.0 belongs to a datatype, whether built-in or programmer-
    defined. When we work with a value, we must use it only in ways supported by its datatype.
    全都是data啊!全是!
  • Ctrl+ t : check syntax; ctrl+ shift+ f : auto format;
  • To declare the datatype of a variable or property, we use this general form, referred to as post-colon syntax(后冒号语法):
    var variableOrPropertyName:datatype
  • As a best practice, in an ActionScript 2.0 program, you should declare the datatype of every variable, property, function parameter; method parameter, function return value, and method return value.
    (PartI 3.0)
  • Macromedia’s documentation uses the term “strict data typing” to refer to ActionScript’s type checking capabilities. Although Macromedia uses “strict” as a synonym for “static,” they are not technically the same. So be aware that the terms “strict,” “static,” and “strong” are often interchanged recklessly in common discussion, as are “weak” and “dynamic.”
    (PartI 3.0)
  • The compiler checks the datatype of the variable (ball1)—not the class of the object actually stored in the variable—to determine what methods and properties are available.
    (PartI 3.3)
  • The rule of thumb is to declare the variable to be of a more general type than the content placed in it (i.e., you can place data of the subtype’s class within a variable declared to be of the supertype’s class).
    (PartI 3.3)
  • The ability to use subtypes wherever a given type is expected enables an important OOP feature: polymorphism. We’ll return to subtypes and polymorphism in Chapter 6.
  • [什么是polymorphis?如何理解?]
    (PartI 3.3)

  • The Object class is the superclass of all ActionScript classes.
    (PartI 3.3)
  • Null: an absence of data; undefined: an uninitialized variable;
    (PartI 3.3)
  • the null and undefined types can be used anywhere, regardless of the type of container they are stored in
    (PartI 3.3)
  • Null是无值;undefined是未定义。它们是两种数据类型,在不考虑数据类型的情况下,null是被认为是undefined的,undefined也可以认为是null。参见null+undefined.fla。
  • ActionScript 2.0 does not support method overloading. However, we’ll see how to simulate overloaded methods and constructor functions in Chapter 4.
    (PartI 3.5.2)
  • var song:Sound = new Sound( );
    song.url = “track3.mp3″; // Error!
    But if we use the
  • [] operator when referring to url, no error occurs, and a new url property is added to the song object:
    var song:Sound = new Sound( );
    song["url"] = “track3.mp3″;
    trace(song["url"]); // Displays: track3.mp3
    This technique adds a new property (in this case, url) to the object instance (in this case, song), not to the class itself (in this case, Sound).
    一种为instance添加property的方法。
    (PartI 3.5.3)

词汇

  • Have been around 见过世面、经验丰富;
  • Hierarchy 层次;
  • Maintain 维护;
  • Concept 概念;
  • Term 术语;
  • Private 私有的
  • Properly 适当的、正确的、完全的、严格的来说;
  • Probably 大概,也许;
  • Aspect 方面;
  • Communicate 通信;
  • Independently 独立的;
  • Furthermore 另外的;
  • Unique 唯一的;
  • Complex 复杂的、综合的、错综的;
  • Particular 详细的、特别的、难以取悦的、考究的;
  • as such 同样的;
  • object-oriented design OOD;
  • Procedural 结构化(的程序设计);
  • Ultimately 最终地,基本上;
  • Traditional 传统的;
  • Invoke 调用;
  • Syntax 语法;
  • Declare 声明;
  • Practice 惯例、习惯;
  • Compile 编译;
  • Compatible 兼容;
  • Void 空的;
  • rule of thumb 单凭经验的方法;
  • Specify 指定;
  • Indicate 指定;
  • Cast 转变、转换;
  • Peruse 细读;
  • primitive 原始的, 远古的, 粗糙的, 简单的

No responses yet

Leave a Reply