PHOTOGRAPHERSONLINEPROOFING.COM

proof of service requirements - www.photographersonlineproofing.com

Menu


Working with ActionScript 3.0 Adobe Flash CS3 uses ActionScript 3.0, a robust scripting language, to extend the functionality


of Flash. While ActionScript 3.0 may seem intimidating to you if you're new to scripting, you can get great results with some very simple scripts. As with any language, you'll do best if you take the time to learn the syntax and some basic terminology. About ActionScript ActionScript, similar to JavaScript, lets you add more interactivity to Flash animations. In this lesson, you'll use ActionScript to attach behaviors to buttons, load text files from a URL, and stop a preloader when the main file has finished loading. As you've done in earlier lessons, you can use ActionScript for such simple tasks as stopping an animation from looping, but you can also use it for much more complex programming tasks. You don't have to be a scripting expert to use ActionScript. In fact, for common tasks, you may be able to copy script that other Flash users have shared. However, you'll be able to accomplish much more in Flash- and feel more confident using the application-if you understand how ActionScript works. This lesson isn't designed to make you an ActionScript expert. Instead, it introduces common terms and syntax, walks you through a simple script, and provides an introduction to the ActionScript language. Additionally, the ScriptAssist.mov movie in the Movies\Lynda.com folder on this book's CD provides an introduction to ActionScript, and especially to its Script Assist feature. If you've used scripting languages before, the documentation included in the Flash Help menu may provide all the additional guidance you need to use ActionScript proficiently. If you're new to scripting and want to learn ActionScript, you may find an ActionScript 3.0 book for beginners helpful. Understanding Scripting Terminology Many of the terms used in describing ActionScript are similar to terms used for other scripting languages. The following terms are used frequently in ActionScript documentation: Variable A variable represents a specific piece of data, which may or may not be constant. When you create, or declare, a variable, you also assign a data type, which determines what kind of data the variable can represent. For example, a String variable holds any string of alphanumeric characters, while a Number variable must contain a number. Suppose you wanted to assign a variable to count the number of frames in a movie. You could name the variable frames, assign an initial value of 0, and set the script to add 1 when it moves to another frame. var frames = 0; currentframes = frames + 1; Note Variable names must be unique, and they are case-sensitive. The variable frames is not the same as the variable Frames. Variable names can contain only numbers, letters, and underscores, and they cannot begin with a number. For example, you can name a variable frames_2 or frames2, but not 2frames or frames 2. Keyword In ActionScript, a keyword is a reserved word that is used to perform a specific task. For example, var is a keyword, used to create a variable. You can find a complete list of keywords in Flash Help. Because these words are reserved, you can't use them as variable names or in other ways. ActionScript always uses them to perform their assigned tasks. Parameters Parameters provide specific details and are the values between parentheses () in a line of code. For example, in the code gotoAndPlay(3); the parameter instructs the script to go to frame 3. Function