1 Reply Latest reply on Aug 8, 2007 9:20 AM by levancho

    Coming from Java/PHP...

    MikeH883
      I have been programming with flex for a couple of days now. I understand most of the concepts of mxml and action script. I am really impressed so far and have decided to develop an upcoming website I am to work on in Flex 2. I have seen a ton of tutorials from Adobe, many of which are helpful, content from lynda.com and safari.oreilly.com, both of which I am a member.

      I am having varying degrees of success picking up mxml and AS3. I understand that mxml gets compiled into AS3. So I am guessing I should start with a more through understanding of AS3? My main stumbling block is the overall program flow. For example I am trying to write a login page that will verify user credentials against an xml response from a PHP call. Seems simple enough:

      <mx:HTTPService id="login_url" url=" http://local.photoeq-flex.com:8888/php/login-flex.php">
      <mx:request>
      <user_name>mike</user_name>
      <user_pw>11112222</user_pw>
      <menu_action>Login</menu_action>
      </mx:request>
      </mx:HTTPService>

      And I have a couple of input boxes and a link button:

      <mx:TextInput id="username_input" x="714" y="10" width="81" text="User name" click="username_input.text=''" backgroundColor="#CFCFD1"/>
      <mx:TextInput id="pw_input" x="714" y="31" width="81" text="Password" click="pw_input.text=''" backgroundColor="#CFCFD1"/>
      <mx:LinkButton id="login_out_btn" x="638" y="10" label="Login" textAlign="left"/>

      But... I am having a hard time trying to figure out how to get the login button to invoke my http call... Is this something that I should be writing into AS3 so I can have more flexibility?

      Basically I just need to ramp up and get a better understanding of the overall process flow of Flex "pages" If anyone has any thoughts on a good resource for this type of information, please let me know... Thanks.



        • 1. Coming from Java/PHP...
          levancho Level 3
          1) add result handler for login service to call function when its back (you can also have seperate function for faultresult back ) :
          <mx:HTTPService id="login_url" url=" http://local.photoeq-flex.com:8888/php/login-flex.php"

          result="myResultHandler(event)" >
          <mx:request>
          <user_name>mike</user_name>
          <user_pw>11112222</user_pw>
          <menu_action>Login</menu_action>
          </mx:request>
          </mx:HTTPService>

          and function that will be called when its back can be :

          private function myResultHandler(event:ResultEvent):void {
          Alert.show("login service is back take some action etc ... ") ;
          }


          2)
          since click attribute of mx:TextInput is event firing when it is clicked, just register function for it :


          <mx:TextInput id="username_input" x="714" y="10" width="81" text="User name" click="myClickHandler(event)" backgroundColor="#CFCFD1"/>

          private function myClickHandler(event:Event):void {
          // call your service etc ..for example :
          Alert.show("login button was clicked") ;
          username_input.text="";
          login_url.send();
          }