开发者

Is it possible to add MXML elements to the main application using Actionscript?

开发者 https://www.devze.com 2023-02-06 17:45 出处:网络
I\'m an Acti开发者_如何学Pythononscript & MXML newbie. There\'s an HTML technique known as innerHTML that allows Javascript to add/delete/edit HTML elements. Can actionscript do something similar

I'm an Acti开发者_如何学Pythononscript & MXML newbie.

There's an HTML technique known as innerHTML that allows Javascript to add/delete/edit HTML elements. Can actionscript do something similar to MXML?

For example, my main application's mxml part is:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Button x="29" y="347" label="Button"/>
</mx:Application>

But after running an actionscript code, I want the user to see the result of:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Button x="29" y="347" label="Button"/>
<mx:RichTextEditor x="183" y="24" title="Title">
</mx:RichTextEditor>    
</mx:Application>

Is this possible with Actionscript inside a MXML file? ALso, if it IS possible, I would appreciate if you would teach me how :) p.s: is this possible with Degrafa library elements?

Thank you!


Unfortunately imposable, if you wont to add components dynamically you should do it inside script tag by using ActionScript 3 Like this:

<fx:Script>
    <![CDATA[
        import mx.controls.RichTextEditor;


        protected function addRichEditor():void{
        var rEditor:RichTextEditor=new RichTextEditor();
        rEditor.x=183;
        rEditor.y=24;
        rEditor.title="Title";
        addElement(rEditor);
        }
    ]]>
</fx:Script>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号