Solved

Convert Bitmap to MoviClip

Posted on 2009-05-15
3
286 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

757 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

20 Experts available now in Live!

Get 1:1 Help Now