2 Replies Latest reply on Feb 15, 2008 7:00 AM by garag

    Using customer component in action script

    garag
      Hi All,

      I have created some customer compenent in action script. These action script class extend some component like combobox and text input.

      Now, I would use these customer component in another customer component, but I have to do this through action script.

      For example, I have created mycombobox in action script that extends the combobox:

      package MyComponents
      {
      import mx.controls.ComboBox;

      public class MyCombobox extends ComboBox
      ...
      }

      after, I would create, always in action script , a custormer component that extend the Panel control and that include and use MyCombobox. I know that it is possible to do this through MXML, but in my case I need to do this via action script.

      If I try to create the following customer component:

      package MyComponents
      {
      import mx.containers.Panel;
      import MyComboBox;

      public class MyPanel extends Panel
      {

      public function MyPanel()
      {
      var mycombo: MyComboBox= new MyComboBox();
      ...
      }
      }

      it doesn't work. I mean that only a panel will be dispalyed without MyComboBox customer component.

      Please, can some one help me.

      Thank you very much
        • 1. Re: Using customer component in action script
          Gregory Lafrance Level 6
          I think you need addChild(mycombo);

          -------------------------------- Test.mxml ----------------------------------
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          xmlns:comp="MyComponents.*">
          <comp:MyPanel/>
          </mx:Application>
          -------------------------------- MyPanel.as --------------------------------
          package MyComponents
          {
          import mx.containers.Panel;

          public class MyPanel extends Panel
          {
          public function MyPanel()
          {
          var mycombo: MyComboBox= new MyComboBox();
          addChild(mycombo);
          }
          }
          }
          ------------------------------- MyComboBox.as -------------------------------
          package MyComponents
          {
          import mx.controls.ComboBox;

          public class MyComboBox extends ComboBox
          {
          }
          }
          • 2. Re: Using customer component in action script
            garag Level 1
            Hi Greg,

            Thank you very much for you answer.

            It works correctly now!

            Regards.