Adobe AS 3 start (for beginners)
Adobe Actionscript 3 based flash project (with flash IDE) has a bit different file structure, than traditional Adobe flash project. Every as3 flash application has a main class where the hole application starts.
Setup a main class to have a starting point for your as3 code
1. ) Create a new actionscript file (as3) and add some code to it:
/*
This class is located to the same folder as main .fla file
so there is no package ie. subfolder defined.
*/
package{
/*
You have to import all the other classes that this class uses.
Also flashes own classes like MovieClip
*/
import flash.display.MovieClip;
/*
Class has to be public to be used by other classes.
Applications main class has to always extend flashes own MovieClip class
*/
public class MyApplication extends MovieClip{
/*
Main function is called when class is initiated.
It's name has to be the same as the classes name
*/
function MyApplication(){
trace("Hello world!")
}
}
}
2.) Save the actionscript file with name “MyApplication.as”
3.) Make a new flash document
4.) On documents properties -> publish -> class write the name for your main class, for example: “MyApplication”
5.) Save the flash document to the same folder as your MyApplication.as file
6.) Test the flash movie!
On the Output panel you will see the “Hello world!” -message