Flex3状态标签 - state的使用
利用state的标签,我们可以给组件设置不同的状态。同时对应不同状态,可以设置相应的属性,样式,添加或删除元件。下面是一个简单的例子:
<?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:states> <mx:State name="1"> <mx:SetProperty target="{title}" name="text" value="告知"/> <mx:SetStyle target="{this}" name="backgroundColor" value="0x008C7F"/> </mx:State> <mx:State name="2"> <mx:SetProperty target="{title}" name="text" value="一般"/> <mx:SetStyle target="{this}" name="backgroundColor" value="0x2680CE"/> </mx:State> <mx:State name="3"> <mx:RemoveChild target="{title}"/> </mx:State> </mx:states> <mx:Label id="title"/> </mx:Canvas>通过currentState属性来切换状态:
<item:TestItem currentState="2"/>