EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - About Bitmap Caching, Scrolling, and Performance

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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.
NOTE
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.

Table of Contents

Related product manuals