480
Animation, Filters, and Drawings
The first section of code in this code example defines two variables:
direction
and
speed
. The
direction
variable controls whether the masked image scrolls from left to
right (
1
) or right to left (
-1
). The
speed
variable controls how many pixels are moved each
time the
onEnterFrame
event handler is called. Larger numbers cause the animation to
move more quickly, although the animation appears a bit less smooth.
The next section of code creates two empty movie clips:
img_mc
and
mask_mc
. A 300 pixel
by 100 pixel rectangle is drawn inside the
mark_mc
movie clip using the Drawing API.
Next, a new object (
mcl_obj
) is created, which you use as a listener for a
MovieClipLoader instance created in the final block of code. This object defines an event
listener for the
onLoadInit
event, masks the dynamically loaded image, and sets up the
scrolling animation. After the image reaches the left or right edge of the mask, the
animation reverses.
The final block of code defines a MovieClipLoader instance, specifies the listener object
you created earlier, and begins loading the JPEG image into the
img_mc
movie clip.
4.
Select Control > Test Movie to test the document.
The image loads and then animates back and forth in a panning motion (side to side
motion). The image is masked at runtime. To see the original image, you can view it
online (
http://www.helpexamples.com/flash/images/image1.jpg
).
About bitmap caching, scrolling, and
performance
Flash Player 8 introduces bitmap caching, which helps you enhance the performance of
nonchanging movie clips in your applications. When you set the
MovieClip.cacheAsBitmap
or
Button.cacheAsBitmap
property to
true
, Flash Player
caches an internal bitmap representation of the movie clip or button instance. This can
improve performance for movie clips that contain complex vector content. All of the vector
data for a movie clip that has a cached bitmap is drawn to the bitmap, instead of to the
main Stage.
NO
T
E
The bitmap is copied to the main Stage as unstretched, unrotated pixels snapped to the
nearest pixel boundaries. Pixels are mapped one-to-one with the parent object. If the
bounds of the bitmap change, the bitmap is re-created instead of being stretched.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...