Below example shows how to add a label control dynamically in AIR or FLEX.

var L : Label = new Label();
L.addEventListener(MouseEvent.CLICK,LabelListener); = “my_label_name”;
L.text = “my Text”;

// This function listens to the mouse click in the above added label.
private function LabelListener(event:MouseEvent):void

Please note that you can add any control by this method.
You can also add any controls inside a container like VBox by this method.
The above code works for only Flex SDK 3 for working in Flash builder or SDK 4 or above you need to change the above code like this.

var ui:UIComponent = new UIComponent();

Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.