Actionscript3.0 Overview

Source: Internet
Author: User
The evolution of ActionScript 3.0 into a powerful object-oriented programming language represents a significant change in the Flash Platform. This change also means that ActionScript 3.0 will creatively establish a rich application program that adapts to the network and become the essential part of the rich Internet application project. In earlier versions of ActionScript, this requirement has been provided to create the power and flexibility to truly participate in online experience. ActionScript 3.0 will promote and develop this kind of performance, provide advanced and highly complex applications that develop strong performance and comfort, and combine code for large databases and face-to-face objects that can be migrated. With the WordPress 3.0, developers may achieve efficient execution and performance on the same platform.

ActionScript 3.0 is based on ecmascript and ecmascript is an internationally standardized language for all programming languages. ActionScript 3.0 also complies with the ecmascript language specification.

ActionScript is executed by the ActionScript Virtual Machine (AVM) embedded in Flash Player. Avm1 is a virtual machine that runs earlier versions of ActionScript. Today's more powerful Flash Platform makes it possible to create interactive media and rich network applications. However, avm1 is squeezing the limit of developers-their project is now at the moment to demand its transformation. ActionScript 3.0 provides a more efficient Virtual Machine-avm2 for executing the Event code, replacing avm1 with a complete one. It will mean that the execution efficiency of ActionScript 3.0 will be at least 10 times higher than that of the previous ones.

The new avm2 virtual machine will be embedded in Flash player8.5, which will become the first virtual machine to execute ActionScript. Of course, the old avm1 will continue to be embedded in Flash player8.5 to be compatible with the previous ActionScript.

There are many products that present their own presentation and Applications in Flash Player, And the animations of these products are often applied to ActionScript to increase interaction and behavior to express their products. In the Macromedia Product family, professional designers and may use ActionScript in several products, such as Macromedia Flash, flex, and Flash Media Servers, to create content and applications in Flash Player. In the flex2 product family, including the latest flex builder 2 ide Based on javase-, it will be the first new experience product in the series that applies the ActionScript 3.0.

Objective of ActionScript 3.0:

We need ActionScript 3.0 to provide an advanced, consistent with the programming model, compliant with industry standards, and will perform an order of magnitude higher than our previous execution performance. Although ActionScript 3.0 represents a new programming model of the Flash Platform, it will also be a basic object-oriented programming language familiar to developers.

The emergence of actionscript3.0 will show the following goals:

Security-it supports certain security so that developers can write clearly and easily maintained code.
Simplicity-this language allows developers to directly read and write projects without frequent reference to manuals.
Performance-this language enables developers to write highly efficient and expressive complex projects.
Compatibility-this language discards nonstandard language standards and provides backward compatibility and meaningful alternation to comply with industry standards. ActionScript 3.0 is a standardized ActionScript 2.0, which adds the XML application (E4X) in ecmascript, so that the language can be integrated into ecmascript as a whole.

Features of ActionScript 3.0:

ActionScript 3.0 consists of two parts: core language and Flash Player API. The core language is used to define the structure of a programming language, such as declaration, representation, condition, loop, and type. The Flash Player API is composed of a series of classes that accurately define the Flash Player function.

ActionScript 3.0 has the ability to explore new features of the computer's residual performance as much as possible. Rule expression supports XML that makes the operation more powerful. Ecmascript for XML (E4X) makes XML a common data type, which greatly simplifies XML processing. The new display listapi makes the virtual objects more consistent. The standardized DOM event model makes the expression and response of those objects more powerful. Of course, these are only part of the many new experiences of actionscript3.0.

Actionscript3.0 language features:

The emergence of ActionScript 3.0 is the integration of ecmascript into the core language of ActionScript 2.0 to comply with its standards and to introduce new improved functional areas. All these features are described and discussed in detail in the reference to the language of ActionScript 3.0. The trial version is available in the Macromedia lab. The following are some new features that developers can summarize for their convenience and usage.

Enhance the ability to handle running errors (enhance the capability of exception handling)

Many seemingly "flawless" Running errors cannot be recorded when you apply the event 2.0. This makes it impossible for Flash Player to bring up a dialog box with an error prompt, just as the Javascript language showed in earlier browsers. That is to say, these missing error reports make us have to spend more energy debugging the ActionScript 2.0 program. The more extensive errors that may easily occur during compilation are introduced in ActionScript 3.0. The improved debugging method enables robust handling of errors in application projects. The prompt running error provides enough notes (example of the source file with an error) and a timeline with a number to help developers quickly locate the location where the error is generated.

Handling of running errors (Exception Handling)

In ActionScript 2.0, comments for running errors mainly provide developers with help. All the help methods are dynamic. In ActionScript and 3.0, the information will be saved to a certain amount, and Flash Player will provide time-based checks to improve the system running security. This information will be recorded to monitor the running status of variables on the computer, so that developers can improve their application projects to reduce memory usage.

Sealed class

ActionScript 3.0 introduces the concept of a sealed class. Sealing classes within the Compilation Time have unique and fixed features and methods, and other features and methods cannot be added. This makes it possible to perform strict Compilation Time checks and create robust projects. Therefore, it can certainly improve the memory usage efficiency, because it does not need to add internal messy commands for each object instance. Of course, dynamic classes can still use keywords declared as dynamic.

Proxy Method
The simplified event processing in ActionScript 3.0 is attributed to its embedded proxy method. In ActionScript 2.0, after a method is disabled, it does not remember any object examples to reference them. When you call a method that has been disabled, unexpected consequences will occur. The MX. utils. Delegate class is frequently used. When you use it, you write the following code:
Mybutton. addeventlistener ("click", delegate. Create (this, somemethod); Delegate. Create (this, somemethod)
In as3.0, this class no longer needs to be introduced. When the method is disabled, its original object instance is automatically remembered. Now, you can simply write "mybutton. addeventlistener (" click ", somemethod );

XML (E4X) in ecmascript)
One of the features of ActionScript 3.0 is its comprehensive support for XML (E4X) in ecmascript, with the latest standard for ECMA-357. E4X provides a natural and fluent language that allows you to quickly construct XML. Like traditional XML parsing interfaces, E4X makes XML a common data type. E4X simplified XML operation will greatly reduce a considerable amount of code for the development of application projects. You can learn more about E4X specifications on this website:
Www.ecma-international.org/publications/files/ecma-st/ecma-357.pdf

Standard expression
The introduction of WordPress 3.0 supports general rules that allow you to quickly search for and quickly operate on characters (strings ). The implementation rules of ActionScript 3.0 are defined in the ecmascript statement of the third edition (ECMA-262 ).

Namespaces)
Namespaces is an innovative mechanism to control the visibility of declarations. Namespaces is similar to conventional control declarations (public, private, and protected) by specifying types. In essence, they can use your selected name through custom paths. Flex, for example, uses an mx_internal namespace as its internal data source. The namespace uses a Uniform Resource Identifier (URI) to avoid conflicts. XML Namespaces can also be used when used together with E4X ..

New Integer type
In ActionScript 2.0, numbers are defined as single-precision numeric types and double-precision floating-point numeric types. The new popular int data type will be added to actionscript3.0. Int Is a 32-bit signed integer data type, so that the CPU can improve the ability to process integer operations in the ActionScript code, int will improve cyclic operations and almost other integer operations without decimal points. Another new data type is uint, a 32-bit unsigned integer type similar to int. Uint is mainly used to represent fields where the color of a cable and other int types cannot work very well.

Features of Flash Player APIs
The Flash Player API consists of a set of classes and functions to enhance the ability of Flash Player to accommodate the ActionScript language. This function serves as a bridge between the core language of ActionScript and the available Flash Platform. This will greatly improve the FLASH application capabilities and play an important complementary role for core languages. There is not enough space to describe the details of the API, but there is a short list to list some new and interesting features:

(1): dom3 event model
The dom3 event model provides a standard method for event messages to interact and communicate between applications, maintain status, and respond to changes. The W3C dom3 event specification is counterfeited. This event model provides a mechanism that is clearer and more efficient than system events in earlier versions of ActionScript. The flex program architecture uses the same dom3 event model as the Flash Player API, so that system events go from the top of the Flash Platform to the end.

(2): display list API
The display interface (API) is composed of a group of related classes that can show simple and vivid flash animations.
New (sprite: Naughty, Genie. A lightweight player, similar to the movieclip class, but more suitable for being the basic class of UI components. The new shape class replaces the old vector shape. These new classes are able to apply the new operation methods to the natural performance and be more dynamic at any time than their predecessors (referring to the old class and the old method.
You do not need to specify depth for the object. Deep management is now automatically created in Flash Player. The new method provides the ability to specify and manage the Z axis for objects.

Of course, this ActionScript 3.0 only outlines some exciting API introductions and language features. When you learn more about as3.0, you will find more. When you want to learn how actionscrip3.0 implements the design of an Application project, you will be able to get started in <ActionScript 3.0 programming>. Of course, <ActionScript 3.0 language reference> ActionScript 3.0 Language Reference) is the authoritative material detailed in the core language of as3.0 and Flash Player API. of course, if you are familiar with ActionScript 1.0 or 2.0, please refer to the new features of ActionScript 3.0 (tips for learning ActionScript 3.0 .).

Flash Player developers are excited to deliver the language preview in the first time. Its new capabilities and improved performance have passed the Macromedia lab's test. You can sense that the event 3.0 will be included in flex builder 2, flex framework, and Flash Player 8.5. I hope you will be as touched by the future of the Flash Platform as we are. We are looking forward to your feedback on this experiment. (Complete !!

Author: Flash Player Engineering director: Gary Grossman.
Flash Player Senior Product Manager: Emmy Huang.

[Center] learning new features of ActionScript 3.0 [/center]

Translation: Zhong Heng blue ideal ----> classic Forum

Actionscript3.0 is a type of secure, standard-compliant, object-oriented language that represents the new program model in the Flash Player. If you are familiar with ActionScript 1.0 or 2.0, you should note some differences when developing an application using actionscript3.0.

To help you easily transition to actionscript3.0, we will start to list some information and some problems you may encounter during the development process. You can find another useful resource for comparing APIs of ActionScript 2.0 and ActionScript 3.0 in the reference to the language of ActionScript 3.0.

1. Data Types must be defined for all variables, parameters, and return values.
Defining data types for all variables, parameters, and returned values is considered an excellent habit, and can help the compiler give you more helpful error messages. Because the Virtual Machine knows the Data Type of it (variables, parameters, and return values) before running, it (defines the data type) can also make the performance better at runtime. In fact, we will give a warning by default because we think this is very important! (Data type is not defined)

2. If no path is declared, it will be an internal one by default, rather than public.

The declared default path will be replaced by a private one (public), meaning that those definitions are visible only to those defined packages, rather than all the code. This is the same as other languages such as Java. Because the actionscript2.0 statement is made public by default, this may become an obvious vulnerability, therefore, we recommend that you create a path for your statement so that it is transparent (meaning some attempts are futile ). to encourage this kind of habit, the actionscript3.0 compiler will bring up a warning when no path is declared!

3. The class is sealed by default, meaning that the Extended features cannot be added during running.
The class can be dynamic or sealed now. Dynamic classes can add other dynamic features during operation, while Sealed Classes cannot. The sealing class is stored in the memory because no other messy signals are required, and the compiler can provide better error feedback. For example, if Class foo is declared, it is sealed. If you declare a dynamic class, use the dynamic keyword, such as dynamic class Foo.

4. If you need to reference the class in a package, it is now included in the package for reference.
The keyword of the package is a new method for the ActionScript 3.0. The Code of ActionScript 2.0 is: Class MX. Controls. Button {...}. Code 3.0: Package MX. Controls {class button {...}}
As in ActionScript 2.0, the file name of a public class is the same as that of the class. Several classes may be placed in the same independent folder, but only one class is public, and its name must match the file name.

5. classes must be imported, even those mentioned
To use the mypackage. myclass class, you must import mypackage. *; or import mypackage. myclass; this is required, even for the classes mentioned, such as using the full name mypackage. myclass. In ActionScript 3.0, the imported file indicates that you want to use a class from another package, while in ActionScript 2.0, it is just a short name. In ActionScript 3.0, the complete class name is used to eliminate ambiguity and is not an alternative to the file import method.

6. The overwrite method must be marked as override.
The override keyword avoids an obvious defect in the overwriting method. For example, an incorrect name or method signature is specified for an overwriting method, or when the name of this overwriting method changes. In addition, the query Code clearly shows that a method has been overwritten. Because it clearly knows whether a method overwrites another method, it can be effectively validated for Compiler compilation. The override keyword is inspired by the override keyword in C.

7. The added attributes should be mandatory data items, not the attributes of objects.
A security type with a lack of objects may cause unexpected errors, so the compiler will also give a warning. Binding attributes of an object, such as selecteditem. Name, will result in a warning. You need to use mandatory data items, such as employeeinfo (selecteditem). Name.

8. The function must define the return value.
This is to ensure a safe data type, so you cannot drop the data type that defines any returned value or get the default type for an object. If a function does not return any value, declare it to return a null value.

9. The proxy method will be established, making event dispatch easier
In ActionScript 2.0, addressing events require the MX. utils. Delegate class or other
Import MX. utils. Delegate;
Mybutton. addeventlistener ("click", delegate. Create (this, onclick ));

In ActionScript 3.0, the method mentioned will automatically remember the object instances it involves. Essentially, this is an automatic proxy. Therefore, the Code may be written as follows:
Mybutton. addeventlistener ("click", onclick );

10. Ignore of indirect reference null or undefined values will not be ignored.
Indirect reference of null or undefined values will be ignored and or notified of undefined values in the previous ActionScript. Currently, the ignore of typeerror will not be ignored. Note that there are null or undefined values in the Code, as well as failures caused by silent messages. The new non-ignore mechanism adapts to the ecmascript specification.

11. The compilation will be conducted in the form of a command line stack and the file name and line progress will appear during the debugging process.
When a running error occurs, the dialog box describes the error and shows the error. Detailed instructions and debugging tool selection can help you locate the error more easily.

12. attributes are no longer bound by default. (Properties are no longer Bindable by default .)
If the property needs to be bound, you must use the [Bindable] metadata tag. (You must declare them to be Bindable by using the [Bindable] metadata tag .)

13. Flash Player API is reorganized into a package
Previously, all classes and functions in flasy playerapi were global. Now they are placed in packages, such as flash. display, Flash. events, and Flash. UI. For example, movieclip is placed in flash. display. movieclip, trace (), gettimer (), and setinterval () into the Flash. util package.

14. The new time class provides a more pure mechanism for time events than the setinterval/setTimeout Functions
The new time analogy setinterval shows more advantages, such as the absence of a time interval and a more advanced, object-oriented interface. We think it is a good habit to replace setinterval/setTimeout with the time class.

15. The event has been forced and must be a subclass of a new event class.
This means that you can no longer use a common example of a Class Object to dispatch an event, and you cannot use the abbreviated object format, that is, {type: "memevent "}. Instead of creating a common object, you need to use event class now.
If you want to obtain other attributes, you need to create a subclass event. This approach is to make the data type safer and more effective.

16. The visual principle extends displayobject. You can define them like other classes. The display list starts to use addchild () to dynamically add components.
As a result, createchild () is no longer recommended. Virtual entities, including textfield, can be displayed like other objects and added to the display list conveniently using addchild () or addchildat. Note that this also involves some other APIs, such as createemptymovieclip () and createtextfield (), which have become the past tense. To create a new textfield, you can use "New textfield ()" instead of "create textfield ()".

17. E4X (ecmascript is XML) is recommended for processing XML in flash.
The E4X in ActionScript is enhanced and complete, providing a new capability for computers. The previous flash XML class can still be used. If you prefer the previous xml api, it is called xmldocument, which is put in the Flash. xml package.

18. When E4X is used, the tostring method cannot be used to mark the entire object and return all the XML. To obtain it, use toxmlstring method.
The tostring method can be used to return certain characters in an XML object. It cannot be used to record the entire XML object. If you need to obtain the marked XML, use the toxmlstring method.

19.... Loop statements of in cannot be used to list attributes and methods of a class. They can only be used to list dynamic attributes of an object.
ActionScript 3.0 describes the Internal Attributes and methods with a new and more advanced mechanism, called describetype. In actonscript 3.0, describetype is used to describe the inherent attributes and methods.

20. You can use an instance of the class you define as a SwF object.
In ActionScript 2.0, SwF objects are always movieclip classes. In actionscript3.0, it may be a subclass of the sprite class. You can define a class for the SWF file in DocumentRoot. When SWF has been downloaded, it replaces this class as the final object.

Translation: Heng ----------- blue ideal-classic Forum

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.