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);
myGroup3.addElement(myButton);
}
The label and id properties get added but not the click. The 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;
What am I doing wrong?