1 Reply Latest reply on Mar 16, 2007 5:00 PM by ntsiii

    Confuse about components

      Hi,

      This is pretty fundamental stuff and I've been working through "Adobe Flex 2 Training from the Source" but it's building a monolithic app and I'm getting lost. I'm just trying to work out some basics.

      I'm attempting to make a simple component but don't know how to get at the variables. Basically, when the user clicks the OK button I need to use those values in the UserInfo class and then using "states" the dialog will go away.

      The Code example explains more.

      Any help appreciated, thanks.

      Paul

      P.S. What happened to the "Add Code" button in the "Post a Message"?

      ------------- my component -------------------------------
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Panel xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" title="Login" height="186" width="268">
      <mx:Label x="10" y="10" text="Name:"/>
      <mx:Label x="10" y="47" text="Class:"/>
      <mx:TextInput x="60" y="8" id="ti_name"/>
      <mx:TextInput x="60" y="45" id="ti_class"/>
      <mx:Button x="157" y="90" label="OK" id="btn_OK" width="63"/>
      <mx:Button x="84" y="90" label="Cancel" id="btn_cancel" width="63"/>

      </mx:Panel>

      ------------- my main file -------------------
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns:v="views.*">
      <v:SimpleLogin />

      <!-- How do I access the variables in SimpleLogon to use my class UserInfo -->

      </mx:Application>

      ------------- my class -------------------
      package valueObjects
      {
      public class UserInfo
      {
      private var userName:String;
      private var userClass:String;

      public function UserInfo(_name:String, _class:String):void
      {
      userName = _name;
      userClass = _class;
      }

      public function getUserName():String
      {
      return userName;
      }

      public function getUserClass():String
      {
      return userClass;
      }
      }
      }
        • 1. Re: Confuse about components
          ntsiii Level 3
          Give the component an id:
          <v:SimpleLogin id="sl" />

          From main.mxml, you can then do:
          var name:String = si.ti_name.text;

          Better, though would be to have the login componet dispatch an event, which you listen for in main app.

          I don't understand where UserInfo fits in.

          Yes, the missing Add code functionality is seriously irritating. Some changes are in the works that might help though.

          Tracy