使用视图状态和变换

 states:应用程序或组件的布局

transitions:变换效果

设计步骤:

1、设计基础状态

2、添加并设置视图状态

3、定义状态间的转换方法

4、创建并绑定变换

Demo:

<? xml version = " 1.0 "  encoding = " utf-8 " ?>
< mx:Application xmlns:mx = " http://www.adobe.com/2006/mxml "  layout = " absolute " >
    
<!-- 定义新的状态集,包括多个State -->
    
< mx:states >
        
< mx:State name = " Advanced " >
            
< mx:AddChild relativeTo = " {panel1} "  position = " lastChild " >
                
< mx:VBox x = " 20 "  y = " 160 "  width = " 160 "  height = " 80 "  id = " myVBox " >
                    
< mx:CheckBox label = " Regular Expression " />
                    
< mx:CheckBox label = " Case Sensitive " />
                    
< mx:CheckBox label = " Exact Phrase " />
                
</ mx:VBox >
            
</ mx:AddChild >
            
<!-- 为LinkButton关联事件,改变状态,即恢复的原始状态 -->
            
< mx:SetEventHandler target = " {linkbutton1} "  name = " click "  handler = " currentState=&quot;&quot; " />
        
</ mx:State >
    
</ mx:states >
    
<!-- 定义变换效果集,包括多个变换Transition -->
    
< mx:transitions >
        
< mx:Transition id = " myTransition "  fromState = " * "  toState = " Advanced " >
            
<!-- 并行效果 -->
            
< mx:Parallel target = " {myVBox} " >
                
< mx:WipeDown duration = " 2000 " />
                
< mx:Dissolve alphaFrom = " 0.0 "   alphaTo = " 1.0 "  duration = " 2000 " />
            
</ mx:Parallel >
        
</ mx:Transition >
    
</ mx:transitions >

    
< mx:Panel x = " 5 "  y = " 5 "  width = " 300 "  height = " 400 "  layout = " absolute "  id = " panel1 "  title = " View States " >
        
< mx:Label x = " 20 "  y = " 70 "  text = " Search " />
        
< mx:TextInput x = " 20 "  y = " 90 " />
        
< mx:Button x = " 185 "  y = " 90 "  label = " Go " />
        
<!-- 通过LinkButton的click事件改变状态,进入Advanced状态 -->
        
< mx:LinkButton x = " 20 "  y = " 120 "  label = " AdvancedOption "  click = " currentState=&quot;Advanced&quot; "  id = " linkbutton1 " />
    
</ mx:Panel >
    
</ mx:Application >

 

Result:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值