Link to home
Start Free TrialLog in
Avatar of TonoNam
TonoNam

asked on

Convert Bitmap to MoviClip

I have the following code to create a new BitmapData. How could I convert this bitmap to a new MovieClip or Sprite?

var myMatrix:Matrix = new Matrix();
myMatrix.tx=55;
myMatrix.ty=55;
var myBitmapData:BitmapData=new BitmapData(400,400,false,0x009966);
var bm:Bitmap=new Bitmap(myBitmapData);
myBitmapData.draw(b_mc, myMatrix);
AddChild(bm);

Avatar of alien109
alien109
Flag of United States of America image

There's no way to cast a BitmapData object to a Sprite or Movieclip datatype. However, you can add it to the sprite/movie clip's display list (make it a child of it).

To add it to a new Sprite or MovieClip
mySprite = new Sprite();
mySprite.addChild(bm);

But you probably already knew how to do that. :)
Avatar of TonoNam
TonoNam

ASKER

For some reason when I add bm to a movieClip of Sprite it does not work. I can just add bm to the main stage by writing:  addChild(bm)    but whenever I try to stuff like  myMovieClip.addChild(bm) there is an error. Is it iposible to add a bitmap to a MovieClip?
ASKER CERTIFIED SOLUTION
Avatar of alien109
alien109
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial