MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 477

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/Galleries.
Moving objects with code
Using ActionScript to move an object is similar to modifying an object's
except that you instead modify the object's
The following procedure animates a dynamically loaded JPEG image and slides it horizontally
across the Stage.
To move an instance on the Stage by using code:
1.
Create a new Flash document called moveClip.fla.
2.
Change the frame rate of the document to 24 fps in the Property inspector.
The animation is much smoother if you use a higher frame rate, such as 24 fps.
3.
Select Frame 1 of the Timeline, and add the following code to the Actions panel:
// Create a movie clip instance.
this.createEmptyMovieClip("img1_mc", 10);
var mcl_obj:Object = new Object();
mcl_obj.onLoadInit = function (target_mc:MovieClip):Void {
target_mc._x = Stage.width;
target_mc.onEnterFrame = function() {
target_mc._x -= 3; // decrease current _x position by 3 pixels
if (target_mc._x <= 0) {
target_mc._x = 0;
delete target_mc.onEnterFrame;
}
};
};
var img_mcl:MovieClipLoader = new MovieClipLoader();
img_mcl.addListener(mcl_obj);
// Load an image into the movie clip
img_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg",
img1_mc);
This code example loads an external image from a remote web server and, when the image
is fully loaded, animates it horizontally across the Stage. Instead of using an
event handler, you could use the
onEnterFrame
image.
4.
Select Control > Test Movie to test the document.
The image loads and then animates from the right side of the Stage to the upper-left
corner of the Stage.
or
property.
_x
_y
setInterval()
Scripting animation with ActionScript 2.0
property,
_alpha
function to animate the
477

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash 8

Table of Contents