Flash MX - Simple Tell Target - Ari Efendi

Advertisement

ads

Hot

Post Top Ad

Your Ad Spot

Saturday, January 1, 2011

Flash MX - Simple Tell Target

Note: Although this tutorial is written for Flash MX, the Actionscript and same basic principles can used for MX 2004, although the location(s) of things mentioned here won't be in the same place.

This tutorial will teach you an important part of creating Flash movies. Tell Target controls other movie clips inside your main movie. This results in being able to create user interaction with your movie as well as create other effects such as "rollover" animation.

Step 1

The first thing you need to do is create your Movie Clip (Insert > New Symbol > Select Movie Clip, or Ctrl+F8, and name it clip). This will be the animation that takes place when the clip is targeted. Make the animation anything you want, but to keep it simple for the tutorial, I just used a basic rectangle with a clockwise motion tween. Make sure you add a Stop Action (Actions window, + > Actions > Movie Control > stop) in the first frame of your M.C. so that it doesn't play right away, and add an Action in the last frame to Go To and Play 2, so it loops.

Step 2

When you have that done, you need to drag it from your library (Ctrl + L) on to your main stage. Position it where you want it and make sure it's selected, and in your Properties Inspector give it an Instance Name of clip.

Step 3

Now you need a way to tell the Movie Clip to play and stop. Create 2 simple buttons. For the start button, right click it, Select Actions and paste in the following code.

on (release) {
clip.play();
}

Note: The actual Tell Target action is deprecated and is unneeded.

For future reference, if you need to target a specific frame in the movie clip, you would apply the following actionscript instead, where X is the frame number in the MC:

on (release) {
clip.gotoAndPlay(X);
}

You can use any OnMouseEvent you want. On Roll Over is good for menu buttons when you want an action to occur when the cursor is over a particular button. But for this tutorial, I chose On Release because we want the Action to occur after a button has been clicked.

Step 4

Then for the stop button, use the same steps as for the start button but give it a stop Action in place of the play Action. You should end up with a movie that gives the following result.

Post Top Ad

Your Ad Spot