说明:
  代码比较简单就不说明了,运行结果图里的第二个按钮就是运行时刻生成的。

代码:
在Flex运行时刻创建UI对象<?xml version="1.0" encoding="utf-8"?>
在Flex运行时刻创建UI对象
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
在Flex运行时刻创建UI对象
在Flex运行时刻创建UI对象
<mx:Script>
在Flex运行时刻创建UI对象
<![CDATA[
在Flex运行时刻创建UI对象    function myfun(){
在Flex运行时刻创建UI对象        import mx.controls.Button;
在Flex运行时刻创建UI对象        var myButton:Button;
在Flex运行时刻创建UI对象        myButton = _root.createChild(Button);
在Flex运行时刻创建UI对象        myButton.label = "runtime's  button";
在Flex运行时刻创建UI对象    }
在Flex运行时刻创建UI对象
]]>
在Flex运行时刻创建UI对象
</mx:Script>
在Flex运行时刻创建UI对象
<mx:HBox>
在Flex运行时刻创建UI对象    
<mx:Button label="my button" click="myfun()"/>
在Flex运行时刻创建UI对象    
</mx:HBox>
在Flex运行时刻创建UI对象
</mx:Application>


运行结果:
在Flex运行时刻创建UI对象

相关文章: