| 包 | mx.states |
| 类 | public class Transition |
| 继承 | Transition Object |
要定义过渡,可将应用程序的过渡属性设置为 Transition 对象的数组。
可使用 Transition 类的 toState 和 fromState 属性来指定触发过渡的状态更改。默认情况下,fromState 和 toState 属性均设置为“*”,表示将过渡应用到视图状态的任何更改。
可以使用 fromState 属性来明确指定要从中进行更改的视图状态,使用 toState 属性来明确指定要更改到的视图状态。如果状态更改和两个过渡匹配,则 toState 属性优先于 fromState 属性。如果超过一个过渡匹配,Flex 将使用过渡数组中的第一个定义。
可以使用 effect 属性来指定应用过渡时要播放的 Effect 对象。通常,它是一个包含多个效果的复合效果对象(如 Parallel 或 Sequence 效果),如下例所示:
<mx:Transition id="myTransition" fromState="*" toState="*">
<mx:Parallel>
...
</mx:Parallel>
</mx:Transition>
MXML 语法
隐藏 MXML 语法The <mx:Transition> tag
defines the following attributes:
<mx:Transition
Properties
id="ID"
effect=""
fromState="*"
toState="*"
/>
默认 MXML 属性effect
另请参见
| 属性 | 定义方 | ||
|---|---|---|---|
![]() | constructor : Object
对类对象或给定对象实例的构造函数的引用。 | Object | |
| effect : IEffect 应用过渡时要播放的 IEffect 对象。 | Transition | ||
| fromState : String = "*" 该字符串指定在应用过渡时要从中进行更改的视图状态。 | Transition | ||
![]() | prototype : Object [静态]
对类或函数对象的原型对象的引用。 | Object | |
| toState : String = "*" 该字符串指定在应用过渡时要更改到的视图状态。 | Transition | ||
| 方法 | 定义方 | ||
|---|---|---|---|
构造函数。 | Transition | ||
![]() |
指示对象是否已经定义了指定的属性。 | Object | |
![]() |
指示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
![]() |
指示指定的属性是否存在、是否可枚举。 | Object | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
![]() |
返回指定对象的字符串表示形式。 | Object | |
![]() |
返回指定对象的原始值。 | Object | |
| effect | 属性 |
public var effect:IEffect应用过渡时要播放的 IEffect 对象。通常,它是一个包含多个效果的复合效果对象(如 Parallel 或 Sequence 效果)。
effect 属性是 Transition 类的默认属性。如果使用 MXML 标签语法,则可省略 <mx:effect> 标签。
| fromState | 属性 |
public var fromState:String = "*"该字符串指定在应用过渡时要从中进行更改的视图状态。默认值为“*”,表示任何视图状态。
可以将该属性设置为空字符串“”,它对应于基本视图状态。
默认值为 "*".
| toState | 属性 |
public var toState:String = "*"该字符串指定在应用过渡时要更改到的视图状态。默认值为“*”,表示任何视图状态。
可以将该属性设置为空字符串“”,它对应于基本视图状态。
默认值为 "*".
| Transition | () | 构造函数 |
public function Transition()构造函数。
<?xml version="1.0" ?>
<!-- Simple example to demonstrate the Transition class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<!-- Define one view state, in addition to the base state.-->
<mx:states>
<mx:State name="Register">
<mx:AddChild relativeTo="{loginForm}" position="lastChild">
<mx:target>
<mx:FormItem id="confirm" label="Confirm:">
<mx:TextInput/>
</mx:FormItem>
</mx:target>
</mx:AddChild>
<mx:SetProperty target="{loginPanel}" name="title" value="Register"/>
<mx:SetProperty target="{loginButton}" name="label" value="Register"/>
<mx:SetStyle target="{loginButton}"
name="color" value="blue"/>
<mx:RemoveChild target="{registerLink}"/>
<mx:AddChild relativeTo="{spacer1}" position="before">
<mx:target>
<mx:LinkButton id="loginLink" label="Return to Login" click="currentState=''"/>
</mx:target>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:transitions>
<!-- Define the transition from the base state to the Register state.-->
<mx:Transition id="toRegister" fromState="*" toState="Register">
<mx:Sequence targets="{[loginPanel, registerLink, confirm, loginLink, spacer1]}">
<mx:RemoveChildAction/>
<mx:SetPropertyAction target="{loginPanel}" name="title"/>
<mx:SetPropertyAction target="{loginButton}" name="label"/>
<mx:SetStyleAction target="{loginButton}" name="color"/>
<mx:Resize target="{loginPanel}"/>
<mx:AddChildAction/>
</mx:Sequence>
</mx:Transition>
<!-- Define the transition from the Register state to the base state.-->
<mx:Transition id="toDefault" fromState="Register" toState="*">
<mx:Sequence targets="{[loginPanel, registerLink,
confirm, loginLink, spacer1]}">
<mx:RemoveChildAction/>
<mx:SetPropertyAction target="{loginPanel}" name="title"/>
<mx:SetPropertyAction target="{loginButton}" name="label"/>
<mx:SetStyleAction target="{loginButton}" name="color"/>
<mx:Resize target="{loginPanel}"/>
<mx:AddChildAction/>
</mx:Sequence>
</mx:Transition>
</mx:transitions>
<!-- Define a Panel container that defines the login form.-->
<mx:Panel title="Login" id="loginPanel"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:Text width="100%" color="blue"
text="Click the 'Need to Register?' link to change state. Click the 'Return to Login' link to return to the base state."/>
<mx:Form id="loginForm" >
<mx:FormItem label="Username:">
<mx:TextInput/>
</mx:FormItem>
<mx:FormItem label="Password:">
<mx:TextInput/>
</mx:FormItem>
</mx:Form>
<mx:ControlBar>
<mx:LinkButton id="registerLink" label="Need to Register?"
click="currentState='Register'"/>
<mx:Spacer width="100%" id="spacer1"/>
<mx:Button label="Login" id="loginButton"/>
</mx:ControlBar>
</mx:Panel>
</mx:Application>