Sunday, June 10, 2007

Flash for Developers

Are you a software developer new to Flash? I will be writing many mini tutorials which will help you overcome your frustrations and turn you into a Flash coding professional.

Introducing Flash CS3

Just a lead-in about the improvements in Flash CS3 (Flash 9): ActionScript 3.0 is simply amazing compared to the previous versions. It is no longer a headache especially now that the compiler reports errors to you and allows you to click on the line that contains the error. I know this is normal for every other language but ActionScript 2.0 was lacking this crucial feature.

Getting Started

So where does a developer start? First, you will want to check out Adobe's video tutorials located here:

http://www.adobe.com/designcenter/video_workshop/

These tutorials will help you get used to the editor and the development environment. The interface will appear very odd at first but remember this was developed for 2D animation.

I Want to Write Code!

If you have a strong programming background, you want to start writing classes, libraries, and find the ins and outs about the language. This can be a challenge at first.

The easiest way to start is by creating a new "Flash File ActionScript 3.0" with a layer called "actions" (this is a standard and should be the only layer containing ActionScript).

Tip: Double click the layer to rename it
From the Window menu, select Actions (or Press F9 on your keyboard) to bring up the actions tab. By default, this will appear in the middle of the screen. Simply drag and drop the tab down to where you see the Parameters tab.
I added the Align tab to beside the Swatches tab, the Components tab near the Library tab, and the Movie Explorer tab to the bottom-right hand side on it's own. I found these to be of critical importance.
Click on the Actions tab and you will be able to start typing ActionScript 3.0 code. But wait! You don't have any components on the screen. Use the Text Tool (the "T" on the left-hand side) and place a text element on the stage. Type Hello in the text area then click the Properties tab. From the dropdown menu, select "Dynamic Text" instead of "Static Text" and type in "textbox_txt" where you see "" (appending _txt is a standard in the Flash world).

Now you have a text area that can be referenced in ActionScript using the following code:

textbox_txt.text = "Hello World!";

Once you type that on the Actions tab, click on Test Movie from the Control menu.
Tip: Hit Ctrl+Enter to test a movie at any time
You should see "Hello World!" in the text area on screen. Wow!... not that impressive, I know.

In the Future

In the next tutorial, I will discuss creating classes in packages (and how to make them work), Document Classes (main), and some of the features of the language that are really helpful.

No comments: