Subscribe

  • Subscribe  

Save memory and loading time when creating bitmaps with AS3

Posted by Jay | May 6, 2008 .

Often we notice that in our zeal to develop appealing web sites and RIA that look perky we may end up designing pages that take inordinately long to upload. Often stylish web pages necessitate the usage of a variety of object including images which take a serious toll on the memory. ActionScript provides developers with the desired flexibility to play around with the web objects. It allows for methods for keeping memory usage under check so that it takes less loading time taken for a web application.

At times we may find that a same bitmap image needs to be replicated at more than one place. If separate objects are being created for each copy then it becomes an overhead on memory. To avoid such issues ActionScript has inbuilt “BitMap” class for representing bitmap images which allows greater flexibility to developers.

The basic constructor for the bitmap class is

Bitmap (bitmapData:BitmapData = null, 

        pixelSnapping:String = "auto", 

        smoothing:Boolean = false);

Essentially a Bitmap object can effortlessly share its reference several such objects. Moreover such sharing is independent of any specific property such as translation.

Now when we need replicate the bitmap, we can create an object of replica where constructor of that replica will create a reference to other or original BMP image , thus a great check on memory overhead. This shown below

var copy1: Bitmap = new Bitmap (Bmpcopy .bitmapData);

Leave a Comment

If you would like to make a comment, please fill out the form below.


Name

Email

Website

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Comments

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


Related Posts

<

Direct TV Offers - usdirect has the best directtv deals