How to add/get Sprite to/from UIComponent

Posted by user955399 on Stack Overflow See other posts from Stack Overflow or by user955399
Published on 2012-06-05T22:36:38Z Indexed on 2012/06/05 22:40 UTC
Read the original article Hit count: 196

Filed under:
|
|
|

How to add Sprite to BorderContainer (UIComponent)?

var sprite:Sprite = new Sprite();
sprite.graphics.lineStyle(10,0);
sprite.graphics.moveTo(40,40);
sprite.graphics.lineTo(60,60);          

mybordercontainer.addChild(sprite);   
//mybrodercontainer is id of BorderContainer created in mxml

This code doesnt work. I cant see Sprite on my BorderContainer. How can I add Sprites on UIComponents, so I can see them? I tried this and it kinda worked:

var comp:UIComponent = new UIComponent();
comp.addChild(sprite);
myborderconteiner.addElement(comp); 

But I dont think, that this is a right way to add Sprites to UIComponents. Is there another method to do that?


Second problem:

When I have few Sprites added to my UIComponent (lines/circles/images or others) how can I receive an object Sprite from that UIComponent, which is containing all Sprites added before to that UIComponent?

I need to create Bitmap from that Sprite and do some things.

I hope I make myself clear

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about flex