Thank you in advance, I'm trying get the position of a button on the array after the button was click. The button is part of a group component.
the component is this:
<fx:Metadata>
[Event(name="eventoConcluido", type="flash.events.Event")]
</fx:Metadata>
<fx:Script>
<![CDATA[
protected function endEventBtn(event:MouseEvent):void
{
var eventTerminado:Event = new Event("eventoConcluido");
dispatchEvent(eventTerminado);
//this.removeAllElements();
}
]]>
</fx:Script>
<s:Button id="endEvent" label="Test" color="black" width="100" click="endEventBtn(event);" />
And in application try to get this:
private var myArray:Array = [];
private var myButton:Button;
protected var comp1:test;
public function addButton():void {
comp1= new test();
myGroup.addElement(comp1);
myArray.push(myGroup.addElement(comp1));
comp1.endEvent.addEventListener(MouseEvent.CLICK, getButton);
}
public function getButton(event:MouseEvent):void {
var ij:int= myArray.indexOf(event.currentTarget);
trace(ij)// always get -1;
}
<s:Button label="Add Button" click="addButton();" />
Is this actually possible?