Your next steps: * Create a simple php page that takes an http request, reads the UserId and Password request parameters. Allow for either form(POST) or querystring(GET) parameters. Keep the authorization logic simple to start with, by hardcoding a userid and password to match. Have the php page return an xml response, something like: <loginresponse status="success" /> Make status="fail" if the user/pwd do not match. Test this page in a browser. * Declare an HTTPService tag in your main app. Set resultFormat="e4x". Declare result and fault handlers. Set the url to the tested php page above * Define a tryLogin function that takes user and password as arguments. In that function, build a request object with userId and password properties and assign the values passed into the function. Invoke send on the HTTPService. * When user clicks the login button, call the tryLogin function, passin in the values entered by the user. * In the result handler, read the event.result as XML, and look at the @status. If success, set the ViewStack.selectedIndex to show the Admin view
Tracy ________________________________ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of stinasius Sent: Friday, December 12, 2008 5:08 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: flex login popup help needed pleaseeeeeeeee Hi Tracy you asked hw far i was, well i decided to redo it from scratch so that i can get guidance. now i have 4 mxml files. one is the main application(login_example.mxml) and there is the Home.mxml which is the default view, the Admin.mxml which requires one to login in order to view it and a login.mxml which is the popup login form. now from there all a ask 4 is a simple cfc that will do the authentication and also how to use it in my flex app. here is my code. "login_example.mxml" <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " layout="absolute" xmlns:view="components.*"> <mx:states> <mx:State name="Log Out"> <mx:SetProperty target="{label1}" name="text" value="Log Out"/> </mx:State> </mx:states> <mx:Script> <![CDATA[ import components.*; import flash.events.MouseEvent; import mx.managers.PopUpManager; import mx.core.IFlexDisplayObject; private var myLoginForm:IFlexDisplayObject; private function showPopUp(e:MouseEvent):void { myLoginForm = PopUpManager.createPopUp(this, Login, true); } ]]> </mx:Script> <mx:Label x="0" y="0" text="Sign In" id="label1" buttonMode="true" useHandCursor="true" mouseChildren="false" click="showPopUp(event)"/> <mx:ViewStack x="0" y="26" id="viewstack1" width="100%" height="100%"> <view:Home id="home"/> </mx:ViewStack> </mx:Application> "Home.mxml" <?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " width="100%" height="100%" backgroundColor="#ff8000"> </mx:Canvas> "Admin.mxml" <?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " width="100%" height="100%" backgroundColor="#400000"> </mx:Canvas> "login.mxml" <?xml version="1.0" encoding="utf-8"?> <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " layout="absolute" title="Login Form" creationComplete="PopUpManager.centerPopUp(this)"> <mx:Script> <![CDATA[ import mx.managers.PopUpManager; ]]> </mx:Script> <mx:Form x="0" y="0"> <mx:FormItem label="User Name:"> <mx:TextInput/> </mx:FormItem> <mx:FormItem label="Password:"> <mx:TextInput/> </mx:FormItem> </mx:Form> <mx:ControlBar> <mx:Button label="Login"/> </mx:ControlBar> </mx:TitleWindow> please guys this would mean alot to me. thanks for sticking up to this point.