As3 learning instance

Source: Internet
Author: User

1. In the control scenario, the movieclip drawn by flash needs to use addchild () to add the Instance name of the movieclip you want to control to the Screen Management display list, in this way, your document class can control the movieclip drawn by flash. If there is a movieclip of mc1 in flash, there is a movieclip of MC2 in mc1. Then you do not need to use addchild (), because after you add mc1 with addchild (), you can directly control the sub-objects under mc1.

The help document explains: Add a displayobject sub-instance to the displayobjectcontainer instance. In this way, adding displayobject will be at the end of the list, that is, the level will be the highest layer. (To add a subitem to a specific index location, use the addchildat () method .) Displayobject: Display objects on the screen displayobjectcontainer: the object containers addchild () and addchildat () are displayed in the list of objects displayed on the screen: Display objects into the display Object List

2. the previously used attributes are not explained in the help document starting: attributes previously used in the movieclip, textfield, And button classes of ActionScript 1.0 and 2.0 (for example, _ Alpha, _ height, _ name, _ width, _ x, and _ y) there are equivalent attributes in the displayobject class in the ActionScript 3.0, but they have been renamed, so they do not start with an underscore.

3. Notes for using addeventlistener to convert movieclip to button

// Convert the movieclip to the movieclip. buttonmode = true; // execute the get operation on the text. Then you 'd better use the following code. Movieclip. mousechildren = false; official help: Specifies whether the object receives mouse messages. The default value is true, which means that by default, any interactiveobject instance on the display list receives mouse events. If you set mouseenabled to false, the instance does not receive any mouse events. Any sub-level of the Instance displayed in the list will not be affected. Use flash. display. displayobjectcontainer. mousechildren to change the mouseenabled behavior of all sub-level objects on the display list.

Example: movieclip. buttonmode = true; movieclip. mousechildren = false; movieclip. addeventlistener (mouseevent. Click, funtionname); function funtionname (Event: mouseevent) {var mcw.event.tar get ;}

4. link a webpage with the as3 button,-_-| no, it becomes so troublesome! Let's see!

Import flash.net. navigatetoURL; import flash.net. URLRequest; // the link is forcibly converted to the URLRequest method, so that the navigatetoURL connection var request: URLRequest = new URLRequest (http://baidu.com/); navigatetoURL (request, "_ blank ");

5. Tools

Package package name {class name {public static funcion method (parameter ...) : Return value {...} }}

6. The installation package here uses aswing as an example (for details about what is aswing, see cn.aswing.org /)

Flexbuilder3: Decompress the compressed package, find the inside aswing_a3_1.2.zip, decompress the package, and copy aswinga3.swc in the aswinga3. For example, I put it in the E:/as3 directory. Create an ActionScript project in fb3, right-click the project, open the Project Properties window, select the ActionScript build path, switch to the library path, and click Add SWC... Browse to the copied file and follow the path where I saved it: e:/as3/aswinga3.swc. then click OK.
Flash CS3 can be decompressed first and then found to aswing_a3_1.2.zip and decompressed. Because flash ide does not support SWC packaged in pure as the compiling library path, We need to copy the entire aswinga3. For example, E:/as3. Then open Flash CS3, click Edit in the menu bar, open the preferred parameter window, click the ActionScript in the list on the left, and then click the settings in the WordPress 3.0 below... Open the class path setting window and add the src directory of aswing. Add the path E: \ as3 \ aswinga3. SRC according to my file path, click OK.
For example, if your package COM is placed in D:/my class/COM, then you choose the path D:/my class/(note that it is not D:/my class/COM)

7. Write subclass super override

Package package name {public class subclass eetends parent class {public static funcion Constructor (variable) {super (variable)} override protected parent class a method or attribute }}

Super ([arg1 ,..., argn]) super. method ([arg1 ,..., argn]) parameter method: function-the method to be called in the superclass.
Argn: *-optional parameters. These parameters are passed to the superclass version of the method or to the constructor of the superclass.
The superclass or parent version of the calling method or constructor. When the super () statement is used in the class constructor, this statement calls the super class version of the constructor. The number of parameters required for calling a superclass constructor must be correct. Note that no matter whether or not the superclass function is explicitly called, The superclass constructor is called. If it is not explicitly called, a call without parameters will be automatically inserted before the first statement in the subclass constructor body. This means that if the constructor is defined in the subclass and the superclass constructor has one or more parameters, you must explicitly call the superclass constructor with the correct number of parameters, otherwise, an error occurs. However, according to the requirements of ActionScript 2.0, calling a super-class constructor does not need to be the first statement in the subclass constructor.

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.