2012-10-21 30 views
0

是否有一種簡單的方法,只使用MXML,在添加和刪除元素的狀態之間轉換。Flex 4簡單的方式在狀態之間轉換

例如:

<s:Group includeIn="state1"/> 
<s:Group includeIn="state2"/> 

能MXML轉換滑出狀態1和狀態2中,例如?

謝謝。

+4

你看了上使用的過渡與狀態的文檔:http://help.adobe.com/en_US/flex /using/WS2db454920e96a9e51e63e3d11c0bf69084-7fab.html? – JeffryHouser

回答

0

除了上面張貼在這裏的鏈接是到一個過渡應用於多個目標的方式:

<?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:views="views.*" > 

    <s:states> 
     <s:State name="home"/> 
     <s:State name="help"/> 
     <s:State name="instructions"/> 
     <s:State name="settings"/> 
     <s:State name="feedback"/> 
    </s:states> 

    <s:transitions> 
     <s:Transition fromState="*" toState="*" > 
      <s:Sequence > 
       <s:Wipe direction="right" duration="350" target="{this}"/> 
      </s:Sequence> 
     </s:Transition> 
    </s:transitions> 

    <views:Home   id="home"  includeIn="home"   width="100%" height="100%" ownerComponent="{this}"/> 
    <views:Help   id="help"  includeIn="help"   width="100%" height="100%" ownerComponent="{this}" /> 
    <views:Instructions id="instructions" includeIn="instructions" width="100%" height="100%" ownerComponent="{this}" /> 
    <views:Settings  id="settings" includeIn="settings"  width="100%" height="100%" ownerComponent="{this}" /> 
    <views:Feedback  id="feedback" includeIn="feedback"  width="100%" height="100%" ownerComponent="{this}" /> 

</s:Group> 

以前的過渡創建擦拭從一個方向到另一個。

下一個過渡淡出從一個視圖到另一個:

<s:transitions> 
    <s:Transition fromState="*" toState="home" > 
     <s:Sequence > 
      <s:Fade target="{this}" alphaFrom="1" alphaTo="0"/> 
      <s:RemoveAction targets="{[home,help,instructions,settings,feedback]}"/> 
      <s:AddAction target="{home}"/> 
      <s:Fade target="{this}" alphaFrom="0" alphaTo="1"/> 
     </s:Sequence> 
    </s:Transition> 
</s:transitions> 

下一個幻燈片中,而滑動休息了一個觀點:

<s:transitions> 
    <s:Transition fromState="*" toState="home" > 
     <s:Sequence duration="1000" > 
      <s:Parallel> 
       <s:Move applyChangesPostLayout="true" targets="{notHomeTargets}" xFrom="0" xTo="{-width}"/> 
       <s:AddAction target="{home}" /> 
       <s:Move applyChangesPostLayout="true" target="{home}" xFrom="{width}" xTo="0"/> 
      </s:Parallel> 
      <s:RemoveAction targets="{targets}" /> 
     </s:Sequence> 
    </s:Transition> 
</s:transitions> 

你將不得不創建一個每個狀態最後一個例子。