Archive for May, 2009
The Actions panel has two different modes. The default mode is Normal mode. In this mode, you cannot directly type scripts character for character. Instead, you must choose from the menu of keywords on the left side of the screen.
This is similar to how scripting in Flash 4 worked. It also makes it nearly impossible to make simple mistakes.
Tour of the Actions Panel in Normal Mode
The top of the panel shows a pop-up menu that shows exactly which script you are currently editing. In Figure 2.1, it reads Actions for Frame 1 of Layer Name Layer 1. This is just a fancy way of saying that it is the script on frame 1, layer 1.
On the left side of the panel is a list of ActionScript commands, sorted into categories. Click a category to expand it and see the subcategories or commands inside.
On the right side of the panel is a large blank space where options appear as you enter various commands and functions. Figure 2.2 shows the Actions panel after you choose to insert the command goto. Notice the Movie Control category has been expanded on the left. The goto command was double-clicked to insert it into the script.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
No Comments »
Flash MX uses a panel system to help you access information and properties of various Flash elements. When you run Flash MX for the first time, you will be asked about how you plan to use Flash, and then your default panel layout will be decided. You can switch between defaults in the Window, Panel Sets menu. This will also determine the size of the ActionScript window, but you can always stretch that window to any size you want.
You can always bring up or close the Actions panel with the F2 key. You can click and drag its title bar to undock the panel from the right side of the screen. You can click and drag the bottom right corner of the screen to enlarge the size of the window, something that you will need to do if you want to write large programs.
Using panels in Flash is simple in some ways and complex in others. It seems complex mostly because so many options are available. It is worth the time to get to know the panels and how they work.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
No Comments »
What elements of Flash can have scripts placed on them?
A2: The main timeline, movie clips, and buttons can have scripts placed on them.
3: Do you have to know ActionScript to be able to tell what a script does?
A3: No. Because ActionScript uses English words, you can usually decipher what a script does just by picking out keywords in the script. Writing your own script, however, takes more skill.
4: How do you bring up the Actions window?
A4: There are two ways. Both require that you first select a key frame in the timeline, a movie clip, or a button. Then you can choose Window, Actions, or use the keyboard shortcut F2 for that menu item
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
No Comments »
If I learned how to program in ActionScript with Flash 4 or earlier, will that help me to learn ActionScript for Flash MX?
A3: Real ActionScript was only introduced with Flash 5. If you’ve scripted Flash in versions 4 or earlier, some of the concepts may be familiar to you. Unfortunately, the leap between Flash 4 and 5 was so great that you pretty much have to start learning Flash scripting all over again. However, if you learned Flash 5 ActionScript, then Flash MX ActionScript is only a little more advanced
Workshop
The quiz questions are designed to test your knowledge of the material covered in this hour. The answers to the questions follow.
Quiz
1: Which version of Flash first contained modern ActionScript?
A1: Flash 5 was the first version to contain what we now know as ActionScript. However, Flash 4 did contain the basic programming constructs, such as conditional statements, loops, and variables.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
No Comments »
What elements of a Flash movie can a script control?
A1: Scripts can control the flow of a movie, making it stop on a frame or jump to any frame in the movie. In addition, scripts can control movie clips. Although buttons can contain scripts, they cannot be controlled by scripts.
Q2: How do I know whether a script is attached to a key frame, movie clip, or button?
A2: In the case of key frames, you will see a little “A” in the timeline if the key frame contains a script. However, there is no way to determine whether movie clips or buttons contain scripts. You just have to select them and open up the Actions window to see. Alternatively, you can use the Movie Explorer panel to seek out scripts.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
No Comments »
ActionScript is a relatively new programming language that borrows from other modern languages such as Java, C++, and JavaScript. ActionScript uses English words and symbols to provide a set of instructions for the Flash movie to follow. It exists so Flash movies can be more interactive than just plain linear animations.
ActionScript can control the flow of a Flash movie, alter movie clips in the movie, allow for user input, communicate with an Internet server, perform calculations, and even play sounds.
You can place ActionScript scripts in the timeline, on buttons, or on movie clips. You can see what scripts are in these locations by selecting the key frame, movie clip, or button and opening the Actions panel.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
No Comments »
Create a new movie.
Place three key frames in the movie by pressing F7 twotimes with the timeline selected.
Use your Flash drawing skills to create different graphics on each frame. For example, you could place a 1 on the first frame, a 2 on the second frame, and a 3 on the third frame.
Now if you run the movie by choosing Control, Test Movie, you will see the movie loop through the three frames.
Return to the main timeline and select the second key frame. Press F2 to bring up the Actions panel.
The left side of the Actions panel shows an expandable list of keywords. Find the stop keyword and double-click it. You will find it under Actions, Movie Control. Now the script window should contain one line that looks like this:
stop ();
Close the Actions window and choose Control, Test Movie to run the movie again. You can also press Command+Return on the Mac or Control_Enter in Windows. It should show you frame 1, frame 2, and then stop. You’ll never see frame 3.
ActionScript has taken control. You’ve created your first script and thwarted Flash’s intentions of looping through all three frames.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
No Comments »
Movie clips differ from plain graphic symbols in that they can be named, and they can have scripts attached to them. You can attach a script to a movie clip in the same way that you attach a script to a button.
Scripts attached to movie clips can be used to control that movie clip or to control other movie clips on the same timeline. Your scripts can detect when a movie clip first appears on the screen, and when a frame in the timeline has passed. This allows you to write scripts that execute repeatedly, once each frame. You can use such scripts to control animation.
In addition to attaching a script to a movie clip, you can also place scripts inside movie clips. After all, a movie clip is just another Flash movie. Inside a movie clip, there is another timeline. You can place timeline scripts on this timeline just like you can with the movie’s main timeline. You can even place buttons inside a movie clip and attach scripts to it. A complex example would be a button with a script inside a movie clip, which is inside another movie clip, which is on the main timeline.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
No Comments »
The third type of symbol, buttons, can also have scripts attached. As a matter of fact, buttons are useless without scripts—they can’t do anything without scripts.
To attach a script to a button, first select the button on the stage. Then choose Window, Actions from the menu. Or use the keyboard shortcut F2.
Notice that the Actions panel has a different title. It looks just like the window in Figure 1.2, but this time, it is titled Actions—Button.
As you might guess, scripts attached to buttons usually contain instructions for Flash to perform if the user clicks the button. Scripts can also react to when the mouse enters or leaves the button’s space. Buttons can also react to key presses. This makes it easy to script a button that has a keyboard shortcut.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
No Comments »
Scripts in the timeline execute when that point in the timeline is encountered as Flash is playing back the movie. For instance, if you place a stop() command in the script attached to a key frame, the movie will stop moving forward at that point. It will continue only if another script tells it to.
Another reason to place scripts in the timeline is when you want to use functions as part of your ActionScript code. Functions are bits of code that can be reused. For scripts throughout the movie to call these reusable functions, they must be placed in the main timeline.
Scripts Attached to Buttons
Elements in Flash are called symbols. A symbol is usually a graphic element. There are three types formally called graphics, movie clips, and buttons. Graphics cannot have scripts attached to them; they are simply static or animated images. Movie clips are like graphics, except that they can have scripts attached to them.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
No Comments »
|
Partner links