Solved

Convert Bitmap to MoviClip

Posted on 2009-05-15
3
287 Views
Last Modified: 2013-11-11
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);

0
Comment
Question by:TonoNam
  • 2
3 Comments
 
LVL 12

Expert Comment

by:alien109
ID: 24399660
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. :)
0
 

Author Comment

by:TonoNam
ID: 24399817
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?
0
 
LVL 12

Accepted Solution

by:
alien109 earned 125 total points
ID: 24411532
What kind of error are you getting? The following code is valid, and shouldn't produce any errors - demonstrating you can add a bitmap object to both a sprite and a movieclip.

var bm1:Bitmap=new Bitmap();
var bm2:Bitmap=new Bitmap();

var sprite:Sprite = new Sprite();
var movieclip:MovieClip = new MovieClip();

sprite.addChild(bm1);
movieclip.addChild(bm2);
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now