2 Replies Latest reply on Nov 9, 2010 3:00 PM by mattcom

    AddChild Button

    mattcom Level 1

      This is probably something very simple but I can't find anything on it.  So I would appreciate any insight you may have.

       

      It's a very simple program that is dynamically creating buttons at runtime based on XML data which will eventually get served by a database query.

       

      Problem:  I can't seem to add a newButton.click = clickHandler() type function through the process of addChild.  Any suggestions?

       

      <mx:Script>

      <![CDATA[

       

       

      import mx.controls.Alert;

       

      import mx.controls.Button;

       

       

      [Bindable]

       

      var buttons:XML =

      <Buttons>

      <Button label="Yes" link="http://papajohns.com"/>

      <Button label="No" link="http://google.com"/>

      </Buttons>

       

      private function makeButtons():void {

       

      for each ( var button : XML in buttons.Button )

      {

       

      var newButton:Button = new Button();

       

      //Modify Properties

      newButton.label = button.@label;

       

       

      //Add the new button to the stage (Screen)

       

       

      this.buttonsBox.addChild(newButton);

       

      }

      }

       

      ]]>

       

      </mx:Script>