|
-
Heli Attack!
[F9] Bitmap Loading from Library
Has anyone figured out a clean way to get Bitmap loading through code in the Flash 9 Alpha?
The embed method that worked in Flex is spitting errors at me, auto-generating a class from the library doesn't want to work, and I really don't think making an MC for every bitmap is the best way around it.
So has anyone had any luck with it? Or should I just chalk it down to it being an Alpha?
-
Hmmm, I know I've seen this somewhere, but I can't remember where. I'll let you know once I find it again.
-
I don't know for certain, but if you can't attach the bitmap directly to the display list, you may have to create a sprite through code and attach it to the sprite first. Then you can attach it to the display list. I will check this to see if it works.
-
Okay, I just did some testing, and here's the deal. I imported a bitmap, and set it to export for as, with an auto-generated class called Test.
If you do var t:Test=new Test(), you get a reference to it, but it extends BitmapData, which isn't a DisplayObject, so you can't just do whatever.addChild(Test). You'll have to create an empty Bitmap, and set it's bitmapData reference to your object. Then you can use that bitmap.
Seems to work fine.
Last edited by Fall_X; 07-21-2006 at 04:25 PM.
-
Yeah something like this:
Code:
var image:test = new test();
var mysprite:Sprite = new Sprite();
mysprite.graphics.beginBitmapFill(image);
mysprite.graphics.drawRect(0, 0, 100, 100);
mysprite.graphics.endFill();
addChild(mysprite);
-
Why use beginBitmapFill when you have the Bitmap class for this? Just use :
Code:
var image:Test = new Test();
var bmp:Bitmap=new Bitmap();
bmp.bitmapData=image;
this.addChild(bmp);
or, a bit shorter :
Code:
var bmp:Bitmap=new Bitmap();
bmp.bitmapData=new Test();
this.addChild(bmp);
-
Heli Attack!
Ah, it's BitmapData *slap*
code:
var bmp:Bitmap = new Bitmap(new Test());
this.addChild(bmp);
Works too, if you guys wanted the quickest way, thanks for the help guys.
Last edited by iopred; 07-21-2006 at 07:40 PM.
-
Didn't realize you could pass Bitmap a BitmapData object in the constructor, nice. But if you want the shortest way, this is even shorter, lol :
Code:
var bmp:Bitmap = this.addChild(new Bitmap(new Test()));
-
Senior Member
-
Error
I keep getting the error - Label must be a simple identifier any ideas?
Cheers,
Sarah
-
What does your code look like?
Last edited by jason merchant; 07-18-2007 at 03:50 AM.
-
half as fun, double the price
You can find an example here:
http://www.senocular.com/flash/tutor...3withflashcs3/
download the source files and check the tutorial about half way down page 2.
Note that Flash CS3 has changed this behavior (from Flash 9 alpha) and now requires that the width and height params be used for the new BitmapData instance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|