Coding with ActionScript
ActionScript is the programming language native and authentic to Flash. It can and should be used to utilize the vast opportunities available in a Flash format website. The first example of an actionscript would be, when you see a web page that opens with an intro animation, the motion will stop and then allow the user to click buttons or navigate elsewhere. Here is an example of a website that uses such a technique, this intro animation is extremely simple as it is only a fade in to the main page.
Sample Splash PageTo make an animation stop so that a user may interact with buttons and other things the actionscript is: stop(); Pretty simple, but we need to discuss a few things first, how to add an actionscript to your timeline, how to find the actionscript panel, and a couple of industry standard tips.
- Create a new topmost layer on your timeline, titled actionscripts.
- At the frame you would like to stop the animation insert a blank keyframe.
- To get the actionscript editor, go to window > actions.
- Select the actionscripts layer, select your blank keyframe, then type stop(); in the actions window.
- To see if your script works, go to control > test movie. Your animation should play once and stop.
Frame Actions
We've just added a timeline initiated actionscript. When the timeline hits the keyframe with the stop(); script, it stops. Other common scripts of this type are:
gotoAndStop( frame# ) or ( scene, frame#); Leaps from the actionscripted frame to the one designated and stops there.gotoAndPlay(frame#) or ( scene, frame#); Leaps from the actionscripted frame to the one designated and plays from there.
Button Symbol Events
Select a button symbol and in the actions panel try adding the following script.
on ( event ) {
someActionToPerform();
}
The event can be any of the following:
Press (merely the touchdown of a mouse button, before it is even released).
Release (after the mouse button is pressed and released). This is generally preferred.
We can use the scripts above as our target for the button. In this example we've created a rewind button.
on ( Release ) {
gotoAndStop(1);
}
Button Symbol Actions
getURL ( url, window, method ); Tells the web browser to go to a URL (note that this must start with http:// if the URL is not located on the same server as the page in which the Flash document is embedded). The window could be "_self" to load the URL in the same window; "_top" to load the URL in the same window and break out of any frames; or "_new" to load the URL in a new window. The method is either "GET" or "POST" and is almost always "GET". Each of the three url, window, and method must be in single or double quotes.
Finding Other ActionScripts
Use the Script Library on the left side of the actions window to find the methods and objects you need for your site. Some amount of programming experience is recommended to understand the library. A simple computer science course or a book on actionscripting will fill in the holes.

