var s : SpriteVisualElement = new SpriteVisualElement();
s.graphics.beginFill( 0xFFFF00 );
s.graphics.drawRect( 0, 0, 100, 20 );
s.graphics.endFill();
s.width = 100;
s.height = 20;
this.addElement( s ) ;
var l : Label = new Label();
l.text = "text";
l.width = s.width;
l.height = s.height;
s.addChild( l );
The follow code seems not to working ( Flex 4.5 ).
- What could cause this issue, and how to fix it ?
It’s not being displayed because you’re not adding Label (which is a UIComponent and works with the component lifecycle) to another UIComponent that will actually instantiate it properly. Your SpriteVisualElement is not made to have UIComponents within it, it’s made to have sprites which can draw itself. Label is waiting for ‘invalidateDisplayList’ to be called so that it can draw itself.
Either do a force draw or use a UIComponent as the container for Label.