?
Solved

Convert Bitmap to MoviClip

Posted on 2009-05-15
3
Medium Priority
?
294 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
Suggested Courses

764 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