1.2 Using Code in Flash

The Flash environment

Flash is a very complete authoring environment, but we will concentrate on coding. As we saw previously, ActionScript is the programming language used by Flash. We will be using the latest version, ActionScript 3. Therefore, it is required that you use at least Adobe Flash CS3, or a more recent version. We will begin by identifying in the Flash environment the elements we need to start coding.

When you open Flash, you will face something like this (Flash CS4 for Mac is featured, but should be similar for other versions):

On the left, we have the tools; the large central area is called the stage; under which is the timeline; and on the right we have several docked windows.

The Actions window

The most important element for us, however, is the Actions window. If you are using Flash for the first time, it is possible that the Actions window is not visible. To make it visible, select “Actions” under the windows menu. The Actions window should appear:

This will be our main interface with Flash, so all other windows will be less important. To optimize your work area, you can dock it, by dragging it to a main area until it snaps, and then decreasing the size of the remaining windows (although this is not required, just a recommendation). We will type in the code in the large blank area of the Actions window.

When you introduce code this way in Flash, the code will be introduced in the “timeline” of the file, meaning it will be available in the first moment (frame) of the file (and consequently, a small “a” appears in the start of the timeline (see first image, under “Flash environment section), meaning there is some code there. This information is not so relevant right now, just some background on how Flash works. If you wander around and start clicking in the Flash environment, your code might accidentally disappear from view, and clicking on this “a” in the timeline will make it reappear. Also, clicking in the “current selection” area in the Actions window (bottom left corner in the image above) will show the code again.

Creating a new file

To create a new file, simply select “New” under the File menu. This window should appear:

Please select, by default, Flash File (ActionScript 3.0).

Saving

Once you have started typing some code, don’t forget to save your document, by selecting “Save” under the File menu. This will generate a file with the “.fla” extension, which is an editable authoring file (and not a final compiled project file).

Running the code

Once we have introduced the appropriate code in the Actions window, we will need to run it. This is done by selecting “Test Movie”, under the Control menu. A new window will appear, showing the execution of the code. This process also generates a file with the “.swf” extension, and the same file name as you gave to the “.fla” file. The “.swf” file is a compressed, compiled file and can be used for the final distribution of the project (for example, as a web project).

Finally, let’s use AS3 as a short version of “ActionScript 3”.

Advertisements

About Nuno Correia

audiovisuals+interaction
This entry was posted in 1. User Interface Design and tagged . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s