5 Replies Latest reply on Mar 25, 2011 7:17 AM by Balaji Sridhar

    adding click property of Button via function?

    digsafe Level 1


      I am trying to add a button to a group in a Flex 4 application from within a function like this;


      public function addButton(myID:Number):void {

      var myButton:Button = new Button();

      myButton.id = ObjectUtil.toString(myID);

      myButton.label = "New Button "+myButton.id;

      myButton.click= textAlerter(myID);


      The label and id properties get added but not the click. T

      he error message says click is an undefined property for spark.components:Button.

      But it is a property when add it to the group like this;

      <s:Button id="myButton" label="My Label" click="myFunction();"/>


      What am I doing wrong?