Advertisement
Jerrian

Revolution.mxml

Jun 2nd, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 1.81 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
  3.                xmlns:s="library://ns.adobe.com/flex/spark"
  4.                xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()">
  5.     <fx:Script>
  6.         <![CDATA[
  7.             import com.jfawcett.models.UserVO;
  8.            
  9.             import mx.controls.Alert;
  10.            
  11.             private var currentUser:UserVO;
  12.             private var connection:NetConnection;
  13.             private var gateway:String = "http://localhost/gateway/";
  14.            
  15.             private function init():void
  16.             {
  17.                 connection = new NetConnection();
  18.                 connection.connect(gateway);
  19.             }
  20.            
  21.             protected function loginButton_clickHandler(event:MouseEvent):void
  22.             {
  23.                 var responder:Responder = new Responder(loginResult, onFault);
  24.                 connection.call("AuthService.login", responder, txtUsername.text, txtPassword.text);
  25.             }
  26.            
  27.             private function onFault(data:Object):void
  28.             {
  29.                 Alert.show( "Service Error" );
  30.             }
  31.            
  32.             private function loginResult(user:UserVO):void {
  33.                 currentUser = user;
  34.                 Alert.show( "Groups: " + currentUser.groups);
  35.             }
  36.         ]]>
  37.     </fx:Script>
  38.     <fx:Declarations>
  39.         <!-- Place non-visual elements (e.g., services, value objects) here -->
  40.        
  41.     </fx:Declarations>
  42.  
  43.     <mx:Accordion width="20%" height="100%">
  44.         <s:NavigatorContent label="Login">
  45.             <mx:Form id="loginForm">
  46.                 <mx:FormItem id="username">
  47.                     <mx:FormItemLabel text="Username:" />
  48.                     <s:TextInput id="txtUsername" />
  49.                 </mx:FormItem>
  50.                 <mx:FormItem>
  51.                     <mx:FormItemLabel text="Password:" />
  52.                     <s:TextInput id="txtPassword" displayAsPassword="true" />
  53.                 </mx:FormItem>
  54.                 <mx:FormItem>
  55.                     <s:Button id="loginButton" click="loginButton_clickHandler(event)" label="Login" />
  56.                 </mx:FormItem>
  57.             </mx:Form>
  58.         </s:NavigatorContent>
  59.     </mx:Accordion>
  60. </s:Application>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement