0 Replies Latest reply on Jan 30, 2008 12:30 AM by vij010

    Code Problem

    vij010 Level 1

      I am creating a login sequence using states. The code works fine, but now I am wanting keyboard access too....so I am now checking for the ENTER key, but the code fails...can you please tell me where I am wrong ?

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
      <mx:State name="success">
      <mx:RemoveChild target="{uname}"/>
      <mx:RemoveChild target="{upass}"/>
      <mx:RemoveChild target="{label1}"/>
      <mx:RemoveChild target="{label2}"/>
      <mx:RemoveChild target="{button1}"/>
      <mx:RemoveChild target="{button2}"/>
      <mx:SetProperty target="{panel1}" name="title" value="Login Success!"/>
      <mx:AddChild relativeTo="{panel1}" position="lastChild">
      <mx:Label x="137" y="103" text="Your Login is Sucessful!" id="label3" color="#400040" fontWeight="bold" alpha="1.0"/>
      <mx:AddChild relativeTo="{panel1}" position="lastChild">
      <mx:Button x="266" y="129" label="Back" click="currentState=''" updateComplete="reset();"/>
      <mx:State name="failure" basedOn="success">
      <mx:SetProperty target="{label3}" name="text" value="Your Login is Not Successful!"/>
      <mx:SetProperty target="{panel1}" name="title" value="Login Failed!"/>
      <mx:SetStyle target="{label3}" name="color" value="#ff0000"/>
      //import the alert control
      import mx.controls.Alert;
      import flash.ui.Keyboard;
      import flash.events.KeyboardEvent;
      import mx.core.UIComponent;

      //check and validate the returning values from the text fields
      public function processlog():void
      if(uname.text=='vijay' && upass.text=='rampage')

      public function initApp():void

      public function testcheck(button1:KeyboardEvent):void
      Alert.show('This works','Heeahahahaehe');

      //reset the textfields to defaults
      public function reset():void

      <mx:Panel x="141" y="126" width="466" height="308" layout="absolute" title="Login Example" id="panel1">
      <mx:TextInput x="134" y="32" id="uname" editable="true" enabled="true" maxChars="50" displayAsPassword="false"/>
      <mx:TextInput x="134" y="62" id="upass" maxChars="50" displayAsPassword="true" editable="true" enabled="true"/>
      <mx:Label x="55" y="34" text="UserName :" id="label2"/>
      <mx:Label x="60" y="64" text="Password :" id="label1"/>
      <mx:Button x="60" y="101" label="Submit" click="processlog();" id="button1"/>
      <mx:Button x="134" y="101" label="Reset" click="reset();" id="button2"/>