Getting Started With AS3 and Flash CS3

Create a Simple Navigation Button and Link it to a Class

Figure 4-1 shows a simple rectangle drawn on the Stage of Main.fla
Now select that rectangle and hit F8 to turn it into a MovieClip symbol called NavBtn. (see Figure 4-2)

Figure 4-2: We now turn our rectangle into a MovieClip symbol and call it NavBtn.
Now create a new AS file and save it as com.identityMine.navigation.NavigationButton.as
And like before we have to set the package, class declaration with a extend on it, our import statement and our Constructor for our new AS file like I have done below:
package com.identityMine.navigation
{
import flash.display.MovieClip;
public class NavigationButton extends MovieClip
{
public function NavigationButton()
{
}
}
}
Inside the Contructor notice I have put a trace statement of that should trace out "NavigationButton Initilized"
Now I am going to go back to Main.fla and delete the NavBtn off the stage. In the Library I am going to right-click on NavBtn and left-click on Linkage and click Export for ActionScript. (see Figure 4-3)

Figure 4-3: Here I am setting our NavBtn's linkage.
Now, this is a little different in AS3 because I can leave the default Class of NavBtn and place my NavigationButton Class in the Base Class. If I do this Flash will see that the NavBtn Class does not exist and prompt me to make one for me. If I do that, then I can reuse this Class on other navigation buttons. So, I am going to do exactly that.
Leave you Class set to NavBtn and change the Base Class to:
com.identityMine.navigation.NavigationButton
Select OK and Flash will tell you that NavBtn does not exist and ask to create it for you. Click OK.
Now at this point if we were to run our application we would not see our NavigationButton trace statement because currently there is no NavBtn being added to the stage. Next we are going to go back to our DocumentClass and make that happen!

