-
Screwy BitmapData OOP Classes
Okay, so I'm trying to make a scrolling shooter that blits all the objects on the screen. My original plan was to use something that looks like this:
//blit background...
for(var i:uint = 0; i<econ.numChildren; i++){
canvasBD.copyPixels(econ.getChildAt(i).BD, new Rectangle(getChildAt(i).bdx, getChildAt(i).bdy, getChildAt(i).bdw, getChildAt(i).bdh),
new Point(econ.getChildAt(i).x-.5*bdx-bdw,econ.getChildAt(i).y-.5*bdy-bdh))
}
Where econ is the container for all enemies, BD is the Bitmap Data for the sprite that each one individually should be displaying and bdx, bdy, bdw and bdh are the area to draw.
The PROBLEM is that when I run this, it says that BD is undefined. I have
public var BD: BitmapData = new BitmapData;
in the parent for enemies, and I've tried
BD = new alien1(96,96);
both in the ADDED event for the child objects and when the individual is created, like:
newnme = new nme1();
newnme.BD = new alien1(96,96);
econ.addChild(newnme);
But nothing works. What am I doing wrong? Should I be doing this a different way?
-
getChildAt returns a DisplayObject. DisplayObject does not define a BD property. You'll have to cast the result of getChildAt to something that does, or something dynamic, like MovieClip.
Tags for this Thread
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
|