RSS

Learn Actionscript 3

0 Comments | This entry was posted on Jun 25 2008

Grant Skinner has released his “Introduction to Actionscript 3″ slideshow from one of his workshops. There is 167 jam-packed slides full to the brim of useful information for those transitioning from as2 to as3.

[ via The Flash Blog ]

How to get a DisplayObject’s BitmapData

2 Comments | This entry was posted on Jun 17 2008

There are many uses to using a DispalyObject’s (MovieClip, Sprite, Loader, etc…) BitmapData. The main reason I find myself using it for is for scaling an image I loaded smoothly. I load the image from an external source, then pull it’s BitmapData and set it’s smoothing to true. Then I can scale the new image without it getting too grainy or pixelated. This is the same effect as selecting the “Allow Smoothing” checkbox if you are using a Bitmap from the library.

In this example, we will get the BitmapData from our MovieClip (myMC) and create a new Bitmap (b), then add it to the stage:
 

var bd:BitmapData = new BitmapData(myMC.width, myMC.height, true,0xFFFFFFFF);
bd.draw(myMC);
var b:Bitmap = new Bitmap(bd);
addChild(b);

I used the BitmapData.draw() method to pull the movie clip’s (myMC) pixel information. I can then use that data when creating a new Bitmap. All that is left is to add the new Bitmap (b) to the display tree (addChild).