i am trying to make a some groups within a predefined group at run time. i can make groups, the code is working fine. Now i have added two buttons in each group which is created in run time. now the problem is one of the button is x . the property of button should be when i click on it it should delete the very specific group in which it is built. please check out the code and tell me what additions should i make.
public var n:Number = 0;
protected function remover (event:MouseEvent):void
{
}
protected function settings(g:Group):void
{
((DisplayObject)(g)).width = "200";
((DisplayObject)(g)).height = "140";
((DisplayObject)(g)).x = "200" ;
((DisplayObject)(g)).y = "200";
var s:String;
s = "NewGroup"+ "X"+ n.toString;
var mybutton1:Button = new Button();
mybutton1.id = s;
mybutton1.label ="X";
mybutton1.addEventListener(MouseEvent.CLICK, remover);
g.addElement(mybutton1);
// setting1(mybutton1);
n++;
}
public function addGroup(event:MouseEvent): void
{
var s:String;
n = n+1;
s = "NewGroup"+ "_"+ n.toString;
var myGroup:Group = new Group();
myGroup.id = s;
main.addElement(myGroup);
// setElementIndex(myGroup, n);
settings(myGroup);
}
]]>
</fx:Script>
<s:Button x="422" id="wow" y="139" label="Add Group" click="addGroup(event)"/>
<s:HGroup id="main" x="6" y="168" width="750" height="490">
</s:HGroup>