hello. i have a simple flex application which should display two states. one is called '_start' and other is 'main'.
basically what i want to do is to display a login screen (username and password) in the '_start' state and after entering details to check for that username in mysql database and if data matches display the 'main' state. in both states i 'include' two different mxml components called 'login_form.mxml' and 'main.mxml'. this is my code: ####################################################################### ####################### ## MAIN APPLICATION ## ####################### <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comps="components.*" layout="vertical" backgroundColor="#FFFFFF" horizontalAlign="center" paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5" currentState="_start"> <mx:states> <mx:State name="_start"> <mx:AddChild position="lastChild"> <comps:loginForm id="_start" width="100%" height="100%" horizontalAlign="center" login="loginHandler()"/> </mx:AddChild> </mx:State> <mx:State name="main"> <mx:AddChild position="lastChild"> <comps:main id="main" width="100%" height="100%" horizontalAlign="center"/> </mx:AddChild> </mx:State> </mx:states> <mx:Script> <![CDATA[ import mx.rpc.events.ResultEvent; import mx.controls.Alert; private function loginHandler(event:ResultEvent):void{ if (event.result.loginsuccess == "yes"){ currentState = "main"; } if (event.result.loginsuccess == "no"){ Alert.show("Wrong information!", "ERROR!"); } } ]]> </mx:Script> <mx:HTTPService id="login_user" result="loginHandler(event)" method="POST" url="php/login.php" useProxy="false"> <mx:request xmlns=""> <username>{loginUser.text}</username> <password>{loginPass.text}</password> </mx:request> </mx:HTTPService> </mx:Application> ########################### ## login_form COMPONENT ## ########################### <?xml version="1.0" encoding="utf-8"?> <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" verticalAlign="top" horizontalAlign="center" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10" layout="absolute" width="310" height="150" status="eDnevnik v0.1.1" roundedBottomCorners="true" title="LOGIN FORM"> <mx:Metadata> [Event(name="login", type="events.LoginEvent")] </mx:Metadata> <mx:Script> <![CDATA[ import events.LoginEvent; private function clickHandler(event:Event):void{ var e:LoginEvent = new LoginEvent("login", loginUser.text, loginPass.text); dispatchEvent(e); } ]]> </mx:Script> <mx:Label x="10" y="12" text="user name:/> <mx:TextInput x="104" y="10" id="loginUser"/> <mx:Label x="10" y="42" text="password:"/> <mx:TextInput x="104" y="40" id="loginPass" displayAsPassword="true"/ > <mx:ControlBar> <mx:Button id="loginButton" label="SUBMIT" click="clickHandler (event)"/> </mx:ControlBar> </mx:Panel> ################################ ## LOGIN EVENT ACTIONSCRIPT ## ################################ package events { import flash.events.Event; public class LoginEvent extends Event { public var username:String; public var password:String; public function LoginEvent(type:String, username:String, password:String) { super(type); this.username = username; this.password = password; } } } ####################################################################### for now my user/pass checking works well. also the login_form component dispatches the event (i can see it in my debugger). i am confused because (if i am right) in my login_form component i am declaring an event of name 'login' and type 'event', right? and in my main application file, when i use that same component i am calling login as loginHnadler() which is of type ResultEvent. i am getting this right for now? so, my flex builder first tells me this error in my main application file: 1067: Implicit coercion of a value of type events:LoginEvent to an unrelated type mx.rpc.events:ResultEvent. which refers to this line: <comps:loginForm id="_start" width="100%" height="100%" horizontalAlign="center" login="loginHandler(event)"/> and after that i get 2 more errors: 1120: Access of undefined property loginUser 1120: Access of undefined property /loginPass on these lines: <username>{loginUser.text}</username> <password>{loginPass.text}</password> what am i doing wrong here? how to handle this 'events' problem? thanks for helping! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to flex_india@googlegroups.com To unsubscribe from this group, send email to flex_india+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/flex_india?hl=en -~----------~----~----~----~------~----~------~--~---