Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Some Flex Code (See related posts)

// A login box component in mxml. This is buggy, I'll adjust this to the clean stuff when I get it figured out.
   1  
   2  <?xml version="1.0" encoding="UTF-8"?>
   3  <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" label="Login">
   4    <mx:Form labelWidth="150">
   5    <mx:Metadata> 
   6        [Event(name="login", type="com.pomodo.events.LoginEvent")] 
   7    </mx:Metadata> 
   8    <mx:Script> 
   9    <![CDATA[ 
  10      import mx.controls.Alert; 
  11      import mx.rpc.events.ResultEvent;
  12      import com.pomodo.events.LoginEvent; 
  13        private function login():void { 
  14            svcAccountLogin.send({login: loginTI.text, password: passwordTI.text}); 
  15        } 
  16        private function handleAccountLoginResult(event:ResultEvent):void { 
  17            var result:Object = event.result; 
  18            if (result == "badlogin") { 
  19                Alert.show("The username or password is wrong.", "Login Error"); 
  20            } else { 
  21                dispatchEvent(new LoginEvent(XML(result))); 
  22            } 
  23        } 
  24    ]]> 
  25    </mx:Script> 
  26    <mx:HTTPService 
  27        id="svcAccountLogin" 
  28        url="/sessions/create_xml" 
  29        resultFormat="e4x" 
  30        method="POST" 
  31        result="handleAccountLoginResult(event)"/>
  32  
  33      <mx:FormItem label="Username" required="true">
  34        <mx:TextInput id="loginTI"/>
  35      </mx:FormItem>
  36      <mx:FormItem label="Password" required="true">
  37        <mx:TextInput id="passwordTI"/>
  38      </mx:FormItem>
  39      <mx:FormItem>
  40        <mx:Button id="loginButton" label="Login" click="login()"/> 
  41      </mx:FormItem>
  42    </mx:Form>
  43  </mx:VBox>

You need to create an account or log in to post comments to this site.


Click here to browse all 5545 code snippets

Related Posts