刚看flex4权威指南,简单花几分钟创建自定义组件,新手之作
main mxml程序如下
<?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:views="views.*">
<views:boke1 id="body" width="100%" height="100%"/>
</s:Application>
mxml组件程序如下
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
<s:states>
<s:State name="State1"/>
<s:State name="nocurrent"/>
</s:states>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
public function handleViewCartClick(event:MouseEvent):void{
this.currentState="nocurrent";
}
]]>
</fx:Script>
<s:Button label="测试1" click="handleViewCartClick( event )" includeIn="State1"/>
<s:Button label="第二次测试用的" includeIn="State1"/>
<s:Button label="测试3" includeIn="State1"/>
<s:Button label="测试4" includeIn="State1"/>
<s:Button label="测试5" includeIn="State1"/>
<s:Label includeIn="nocurrent" text="跳转成功" width="62" height="36"/>
</s:Group>
简单自定义组件,保持更新!
转载于:https://blog.51cto.com/bocaipeng/608008