3 Replies Latest reply on Feb 22, 2011 11:03 AM by JeffryHouser

    problems with a custom component

    jaguado001

      Hi,

       

      I'm stating with Flex and I`ve make a component but I`ve a problem. In this component I've one button and two links and I'm handling the click event but when I press the button or one of the links they do anything. This is the code of my component. If someone can say me what I'm making wrong. Thanks.


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Form xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx" width="364" height="120">

      <fx:Metadata>
      [Event(name="informacionLoginIntroducida", type="flash.events.Event")]
      [Event(name="olvidoPasswordPulsado", type="flash.events.Event")]
      [Event(name="registroUsuarioPulsado", type="flash.events.Event")]
      </fx:Metadata>

      <fx:Script>
      <![CDATA[
      import mx.controls.Alert;

      protected function olvidoPwdLink_clickHandler(event:MouseEvent):void
      {
      Alert("En olvidoPwdLink_clickHandler");
      dispatchEvent(new Event("olvidoPasswordPulsado"));
      }


      protected function registroLink_clickHandler(event:MouseEvent):void
      {
      Alert("En registroLink_clickHandler");
      dispatchEvent(new Event("registroUsuarioPulsado"));
      }


      protected function loginButton_clickHandler(event:MouseEvent):void
      {
      Alert("En loginButton_clickHandler");

      if (username.text == "" || username.text == "nombre de usuario" || pwd.text == "" || pwd.text == "contraseña") {
      Alert("Por favor, asegúrese de introducir los siguientes detalles:\nSu nombre de usuario\nSu contraseña");
      } else {
      dispatchEvent(new Event("informacionLoginIntroducida"));
      }
      }


      protected function username_focusInHandler(event:FocusEvent):void
      {
      if (username.text == "nombre de usuario") {
      username.text = "";
      }
      }


      protected function username_focusOutHandler(event:FocusEvent):void
      {
      if (username.text == "") {
      username.text = "nombre de usuario";
      }
      }


      protected function pwd_focusInHandler(event:FocusEvent):void
      {
      if (pwd.text == "contraseña") {
      pwd.text = "";
      }
      }


      protected function pwd_focusOutHandler(event:FocusEvent):void
      {
      if (pwd.text == "") {
      pwd.text = "contraseña";
      }
      }

      ]]>
      </fx:Script>

      <mx:HBox>
      <mx:VBox>
      <mx:FormItem width="188">
      <s:TextInput text="nombre de usuario" id="username" maxChars="8"  width="170" focusIn="username_focusInHandler(event)"  focusOut="username_focusOutHandler(event)"/>
      </mx:FormItem>
      <mx:FormItem width="188">
      <s:TextInput text="contraseña" id="pwd" maxChars="8" width="170"  focusIn="pwd_focusInHandler(event)"  focusOut="pwd_focusOutHandler(event)"/>
      </mx:FormItem>
      </mx:VBox>
      <mx:VBox>
      <mx:FormItem>
      </mx:FormItem>
      <mx:FormItem>
      <s:Button id="loginButton" label="Inicio de sesión"  click="loginButton_clickHandler(event)"/>
      </mx:FormItem>
      </mx:VBox>
      </mx:HBox>
      <mx:HBox>
      <mx:LinkButton id="olvidoPwdLink" label="¿Has olvidado tu  contraseña?" color="#24379A"  click="olvidoPwdLink_clickHandler(event)"/>
      <mx:Text text="|"/>
      <mx:LinkButton id="registroLink" label="Regístrese ahora" color="#24379A" click="registroLink_clickHandler(event)"/>
      </mx:HBox>
      </mx:Form>