Revision as of 17:01, 14 January 2015 by Hesperides (1 revision imported)
|Flash11 (CS5) Flash10 (CS4) <|
|Table of contents|
Using Flash 10 (CS4) and ActionScript 3.0
- To introduce Scripting, Classes and objects.
- To demonstrate the use of a trace as a debugging option
- To create a display object on the stage using ActionScript 3.0
- To create an external ActionScript 3.0 class file
References: Rosenzweig (2008)
Based on Rosenzweig (2008, pp.9-10)
- Create New > Flash File (ActionScript 3.0)
- Right click on Layer1 / frame 1 and choose Actions (or single click on the frame then [F9])
- Type in
- Close the window (you actually don’t really have to - but the output pane may be hidden behind it!)
- To test it, type [Ctrl]+[Enter], and output pane is displayed:
- The flash movie stage does not show anything (as we are using a debugging command) so the results are displayed in a debugging "output" window.
- This will only work while testing the movie.. so onto the next example…
Using a display object
Based on Rosenzweig (2008, pp12-13)
Create a new movie with the following ActionScript
- Then run the movie ([Crtl]+[Enter], a little “Hello World” appears on the stage
- addChild adds the txtComment object to the stage
- The stage size is set in the movies properties, so if you resize it the Hello World” may disappear! (I have set my stage size to 250x250 to show all the things on one screen shot)
- The position of “Hello World” can be set through the code.
Using an external class
Based on Rosenzweig (2008, pp13-15)
- Create a new external ActionScript File: File > New > ActionScript File
- .. and enter the following (Note the class, function and filename all need to be the same)
- Use the tick to check the syntax (top left)
- Save the file as HelloWorld3.as
Include the class into a flash movie
- Create new Flash File (ActionScript 3.0)
- Save the movie HelloWorld3.fla (otherwise it won't be able to figure out how to link the 'as' file)
- Assign the document class to the movie in the properties pane (our ActionScript file: HelloWorld3)
- Then run the movie
- A class can be though of as the code part of the object and defines what data is associated and what functions it can perform.
- The code cannot be pasted directly from this page (as it contains formatting)
- Reminder that case is significant (e.g. txtComment is not the same as txtcomment )
- For an external class the class, function and filename all need to be the same
- Rosenzweig, G. (2008) ActionScript 3.0: Game Programming University. Que. ISBN: 0-7897-3702-1.