Flash Action Scripting: Six Scripts Every Beginner Should Learn

Flash Action Scripting: Six Scripts Every Beginner Should Learn

Flash Action Scripting: Six Scripts Every Beginner Should Learn

For years, Flash has been the choice of many Web designers who want to create banner ads, Web sites and more. But Flash is not just about animation or graphics; there is also a programming side to this software , and it can be difficult to learn. But if you’re just starting out, these six types of Action scripting scripts may help you get started with the programming side of Flash.
The Stop Function –

This is one of the most basic and easy action script codes to learn. All it does is stop the Flash movie. So if you’re animating a scene for an online movie and want the movie to stop on a certain keyframe then you just need to utilize the stop command. Here’s the script: stop();

The Play Function –

Obviously, this action script code does the exact opposite of the stop function. If you’re at a point in your Flash movie where you want the movie to move forward then you just utilize the play function. Here’s the code snippet: play();

Linking to Another Site –

So what do you do if you want to link to another website such as CNN or something? You’ll just use the link function, which acts just like the “a href” function in HTML. Instead of “a href” you simply have “getURL”. All you have to do is place the website address between the two quotation marks that follow the “getURL” code, and you will have successfully linked to another website. Here’s the code: getURL(“”);

Loading And Unloading A Movie –

Loading and unloading a movie is a simple code that can become extremely complex, depending on the type of project you are working on. You will use this script mainly to reduce the file size of your movie.

So if you use lots of graphics in your Flash movie/Web site then you will probably want to take advantage of the load and unload movie scripts. After all, the faster your movie loads the happier your web viewers will be. Nobody want to wait very long. Here’s the scripts: loadMovie(); amp; unloadMovie();

The On Release Code –

The on release script is one of the more important ones that you’ll use. Most of the time you will place the above codes within the on release script. Here’s an example:

on (release) {
getURL(“weather.com”, “_self”);
}

It’s fairly self explanatory. As for the word release, you’re not limited to just that. Basically release means that the web surfer will click on the button where the on release code is, which will then tell the script to take the web surfer to the weather.com website. But you can also use rollover, rollout, drag over, drag out, press, release outside, and key press. Here’s another example with the above code:

on (rollover) {
getURL(“weather.com”, “_self”);
}

Just switch the words release and rollover and you’re done. It’s really that simple. Feel free to experiment with the other words if you like. After all, experimenting is the best way to learn.

Creating Movement With Code –

In order to create movement with code, you’ll need to create a movie clip in Flash. You can give it a name if you like or not; it really doesn’t matter in this case. After your movie clip is created, press F9 to bring up the actions box. Then simply copy and paste this code into the action box(make sure you’re in expert mode):

onClipEvent (enterFrame) {
_y += (_root.name -_y)/2.9;
}
onClipEvent (load) {
_root.name = 480;
}

You can test this code by pressing ctrl and enter simultaneously. If you were like me then you simply created a square, and turned it into a movie clip. It can be a circle or whatever you prefer. No matter what it is, it should have moved down when you tested it.

This is how the script works. Remember your Algebra classes? Well, this script actually utilizes a tiny bit of Algebra. “X” and “Y”. Basically, “X” goes left to right and “Y” goes up and down. So if you want the above code to go from right to left then you would change the “Y” to an “X”. Like this:

onClipEvent (enterFrame) {
_x += (_root.name -_x)/2.9;
}
onClipEvent (load) {
_root.name = 480;
}

The 2.9 has to do with the speed of the movie clip. So if you want the object to go faster you lessen the 2.9 to something like 1.5. To decrease the speed, you simply increase the 2.9 to something like 5 or 10. You can go higher if you like. Or lower.

As for “_root.name”, this is the name that you have given the object/movie clip. If you were to have two objects in your Flash movie instead of one then you would need to provide another name for the other movie clip. So you could have “_root.name2” or something like that. Only the word name will need to be changed. Leave the “_root” alone.

And the number 480 represents how far the object/movie clip travels across your page. You can change it to whatever you like but be careful. If you increase or decrease the number too much then the object will disappear from the screen. You’ve told the object to basically go beyond what your screen can view.

The above codes that I have shown you only scratch the surface of the amount of Actionscripting that can be accomplished with Flash. However, you will need to learn these scripts in order to build a website entirely out of Flash. Even just a basic banner ad will require knowledge of some of these scripts.

Pearl Hunt

Uncategorized

No description. Please update your profile.