If you already know the basics of Flash, using tools and creating animations, you may want to add some interactivity to your work. ActionScript, an object oriented programming language built into Flash, is the key to this. Adi Reddy Mora explains the basics of ActionScript.
Basic Flash ActionScript for Designers (Page 1 of 4 )
I'll be using Flash MX 2004, and I'll assume that you're already familiar with working on the Timeline and creating animations with keyframes. You should also know how to create buttons and movie clips, as well as being able to publish a movie. It may be helpful to review my previous article, What is ActionScript for some real basics. That said, let's look at editing movie clips.
Controlling movie clips
To control movies with ActionScript, you should name movie clip instances, which will uniquely identify them as objects. As objects, ActionScript can controlled them. When you give a movie clip instance an instance name, the instance name identifies it as an object of the MovieClip class.
You can use global ActionScript functions or the methods of the MovieClip class to perform tasks on movie clips. To use a method, you need to invoke it by using the target path of the instance name and then the method name and parameters, as shown in the following examples:
// Plays the movie clip with instance name “anim_mc” anim_mc.play();
// Sends the playhead to frame 3 in the movie clip with instance name // “subanim_mc” and plays it, which is inside “anim_mc” anim_mc.subanim_mc.gotoAndPlay(3);
Note that using suffix _mc is a good practice while naming movie clip instance names.
You can use the following methods and properties to control movie clips:
// Stops the movie clip “anim_mc” anim_mc.stop();
// Sends the playhead to frame 10 in the movie clip with instance name // “anim_mc” and stops it anim_mc.gotoAndStop(10);
// Sends the playhead to the next frame of the movie clip anim_mc.nextFrame();
// Sends the playhead to the previous frame of the movie clip anim_mc.prevFrame();
Besides the methods of the movie clip class, you can also use its properties to control behaviour and appreance.
// Sets the transparency value of a movie clip instance anim_mc._alpha = 60;
// Sets the height of a movie clip instance, in pixels anim_mc._height = 400;
// Sets the width of a movie clip instance, in pixels anim_mc._width = 300;
// Sets the degree of rotation of a movie clip instance anim_mc._rotation = 15;
// Value that determines whether a movie clip instance is // visible or hidden (true or false) anim_mc._visible = false;
// Sets the xcoordinate of a movie clip instance anim_mc._x = 25;
// Sets the ycoordinate of a movie clip instance anim_mc._y = 125;