BB23850 BB23850 - 1 month ago 11
ActionScript Question

How to use MXML mx.controls.Label in ActionScript

I have one AS3 application which was developed entirely in AS3 without using single line of code in MXML. Of late I am realizing that MXML has some rich controls which are not provided in open source Apache Flex SDK. One library which is of most interest to me in mx.controls, it includes Label, DataGrid etc.

Now, I want to extend my AS3 application to call mxml compiled into swf file. I tried to import mx.controls inside my AS3 programs but it does not sense that. Please tell me if I am doing anything wrong. If I am able to import mx.controls inside as3 class it would save me a lot of time. Can I do this?

Alternatively, I am trying to write a few applications in mxml and then call (.swf) in AS3. Is it possible?

I tried Googling but all examples are pointing to using ActionScript inside MXML with [CDATA[]]. But I want the inverse. Calling MXML from ActionScript.

Please explain me at nuts and bolts level as I am struggling with this a lot.

thanks in advace

Answer

You can't do that because Flex, that uses MXML, is framework built on top of the Actionscript. But you can do reverse. In Flex MXML you can use Actioscript code, and you can also use Flash components like Sprite, MovieClip... by using UIComponent or SpriteVisualElement as their parent container.

Comments