actionscript 3 - Can I draw the same DisplayObject multiple times? -


i have loop runs , adds textfield array sprite, , draws sprite bitmapdata object. when reference drawn textfield, nothing drawn bitmapdata.

public class pocket extends sprite {     public var inventory:array = [textfield1, textfield2, textfield3]; //array of textfields, populated class     public var order:array = [0,1,2,1]; //array of ints indicating order of items in "inventory" should displayed (the error lies when element repeated - in case, 1      public function getitem(index:int):array     {         var bitmaps:array = new array();          for(var i:int = 0; < order.length; i++)         {             var bitmapdata:bitmapdata = new bitmapdata(32, 32);              var background:sprite = new sprite();             background.graphics.beginfill();             background.graphics.drawrect(0,0,32,32);             background.graphics.endfill();             bitmapdata.draw(background); //this executes expected              var sprite:sprite = new sprite();             sprite.addchild(inventory[order[i]]);              bitmapdata.draw(sprite);              var bitmap:bitmap = new bitmap(bitmapdata);             bitmaps.push(bitmap);              sprite.removechild(inventory[order[i]]);         }         return bitmaps;     } } 

when last element in order called (1), resulting bitmap not contain textfield.

example

when loop runs first time, adding textfield inventory[0] sprite, sprite drawn expected. second box drawn, using inventory[1]. however, when run same code trying draw inventory[1] second time, nothing happens. same happen if try draw inventory[0], if use textfield has yet added sprite (ex. inventory[2], should 1 exist), draws expected.

any ideas? in advance.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -