首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

沿袭父类并继承父类的控件

2013-08-04 
继承父类并继承父类的控件?xml version1.0 encodingutf-8?s:Application xmlns:fxhttp://ns.ad

继承父类并继承父类的控件
<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:Vgroup="com.view.Vgroup.*"><s:layout><s:VerticalLayout/></s:layout><Vgroup:ChildVGroup2/><Vgroup:ChildVGroup/></s:Application>?ChildVGroup:

?

<?xml version="1.0" encoding="utf-8"?><Vgroup:ParentVGroup xmlns:fx="http://ns.adobe.com/mxml/2009"    xmlns:s="library://ns.adobe.com/flex/spark"    xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:Vgroup="com.view.Vgroup.*"><fx:Script><![CDATA[override protected function createChildren():void{var currentMxmlContent:Array = super.mx_internal::getMXMLContent();var allMxmlContentArray:Array = mxmlContentArray.concat(currentMxmlContent);mxmlContent = allMxmlContentArray;super.createChildren();}]]></fx:Script><s:Button label="tv3"/><s:Button label="tv4"/><s:Button label="tv5"/><s:Button label="tv6"/></Vgroup:ParentVGroup>

??ChildVGroup2 和 ChildGroup 一样,只是button的label不一样,以此来区别。

ParentVGroup:

<?xml version="1.0" encoding="utf-8"?><s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009"   xmlns:s="library://ns.adobe.com/flex/spark"   xmlns:mx="library://ns.adobe.com/flex/mx"><fx:Declarations><!-- Place non-visual elements (e.g., services, value objects) here --></fx:Declarations><fx:Script><![CDATA[public var mxmlContentArray:Array;//在加载类的时候,第一次会加载Parent的容器的child(例如v1,v2),然后放到这个数组中。//在默认的实现当中,如果parent的子类也有child,那么就会覆盖这个数组。所以我们要先把parent的child的保存起来。override public function set mxmlContent(value:Array):void{super.mxmlContent = value;if(!mxmlContentArray){mxmlContentArray = value;}}]]></fx:Script><s:Button label="v1"/><s:Button label="v2"/></s:VGroup>

?

?

?

?

?

?

?

热点排行