mech7
%Europe/Berlin %704 %2006, 17:54
Ik ben een beetje aan het proberen met de transitions maar bij het terug gaan naar de base state gebeurt er niks weet iemand wat er fout is? :(
loginForm.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:states>
<mx:State name="registerForm">
<mx:AddChild relativeTo="{form1}" position="lastChild">
<mx:FormItem label="Email:" required="true">
<mx:TextInput id="emailInput" displayAsPassword="true"/>
</mx:FormItem>
</mx:AddChild>
<mx:SetProperty target="{registerButton}" name="label" value="Register"/>
<mx:SetProperty target="{loginPanel}" name="title" value="Register"/>
<mx:AddChild relativeTo="{controlbar1}" position="lastChild">
<mx:LinkButton label="Login" click="currentState=''"/>
</mx:AddChild>
<mx:RemoveChild target="{linkbutton1}"/>
<mx:AddChild relativeTo="{form1}" position="lastChild">
<mx:FormItem label="Firstname:" required="true">
<mx:TextInput id="firstnameInput" displayAsPassword="true"/>
</mx:FormItem>
</mx:AddChild>
<mx:AddChild relativeTo="{form1}" position="lastChild">
<mx:FormItem label="Lastname:" required="true">
<mx:TextInput id="lastnameInput" displayAsPassword="true"/>
</mx:FormItem>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:transitions>
<mx:Transition toState="registerForm">
<mx:Resize duration="500" target="{this}"/>
</mx:Transition>
<mx:Transition toState="">
<mx:Resize duration="500" target="{this}"/>
</mx:Transition>
</mx:transitions>
<mx:StringValidator id="userValidator" property="text" source="{usernameInput}"/>
<mx:Panel title="Login" id="loginPanel">
<mx:Form id="form1">
<mx:FormItem label="User name:" required="true">
<mx:TextInput id="usernameInput"/>
</mx:FormItem>
<mx:FormItem label="Password:" required="true">
<mx:TextInput id="passwordInput" displayAsPassword="true"/>
</mx:FormItem>
</mx:Form>
<mx:ControlBar id="controlbar1">
<mx:Button label="Submit" click="mx.controls.Alert.show('You clicked','Click')" id="registerButton"/>
<mx:Spacer width="100%" />
<mx:LinkButton label="Register" id="linkbutton1" click="currentState='registerForm'"/>
</mx:ControlBar>
</mx:Panel>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
]]>
</mx:Script>
</mx:Canvas>
main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:forms="forms.*">
<forms:loginForm id="loginComponent"/>
</mx:Application>
loginForm.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:states>
<mx:State name="registerForm">
<mx:AddChild relativeTo="{form1}" position="lastChild">
<mx:FormItem label="Email:" required="true">
<mx:TextInput id="emailInput" displayAsPassword="true"/>
</mx:FormItem>
</mx:AddChild>
<mx:SetProperty target="{registerButton}" name="label" value="Register"/>
<mx:SetProperty target="{loginPanel}" name="title" value="Register"/>
<mx:AddChild relativeTo="{controlbar1}" position="lastChild">
<mx:LinkButton label="Login" click="currentState=''"/>
</mx:AddChild>
<mx:RemoveChild target="{linkbutton1}"/>
<mx:AddChild relativeTo="{form1}" position="lastChild">
<mx:FormItem label="Firstname:" required="true">
<mx:TextInput id="firstnameInput" displayAsPassword="true"/>
</mx:FormItem>
</mx:AddChild>
<mx:AddChild relativeTo="{form1}" position="lastChild">
<mx:FormItem label="Lastname:" required="true">
<mx:TextInput id="lastnameInput" displayAsPassword="true"/>
</mx:FormItem>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:transitions>
<mx:Transition toState="registerForm">
<mx:Resize duration="500" target="{this}"/>
</mx:Transition>
<mx:Transition toState="">
<mx:Resize duration="500" target="{this}"/>
</mx:Transition>
</mx:transitions>
<mx:StringValidator id="userValidator" property="text" source="{usernameInput}"/>
<mx:Panel title="Login" id="loginPanel">
<mx:Form id="form1">
<mx:FormItem label="User name:" required="true">
<mx:TextInput id="usernameInput"/>
</mx:FormItem>
<mx:FormItem label="Password:" required="true">
<mx:TextInput id="passwordInput" displayAsPassword="true"/>
</mx:FormItem>
</mx:Form>
<mx:ControlBar id="controlbar1">
<mx:Button label="Submit" click="mx.controls.Alert.show('You clicked','Click')" id="registerButton"/>
<mx:Spacer width="100%" />
<mx:LinkButton label="Register" id="linkbutton1" click="currentState='registerForm'"/>
</mx:ControlBar>
</mx:Panel>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
]]>
</mx:Script>
</mx:Canvas>
main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:forms="forms.*">
<forms:loginForm id="loginComponent"/>
</mx:Application>