Hello everybody
I have a dialogBox with 2 buttons - ok_btn and cancel_btn. The code is in a Class - testDialog.
There are 2 issues:[LIST=1]
[]When any of the 2 buttons clicked, they dismiss the dialogBox without sending any alert to the parent (main time-line).
[]How to trap the clicked buttonId in the parent.
[/LIST]I have just an idea of the solution as dispatching an event in the child and listen for that event in the parent. But, unfortunately, I don’t know how to go about it.
To make my point clear, here is the code:
package
{
import flash.display.*;
import flash.events.*;
public class TestDialog extends MovieClip
{
private var _btnSelected: String = "";
public function TestDialog()
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e: Event): void
{
ok_btn.addEventListener(MouseEvent.CLICK, ClickHandler);
cancel_btn.addEventListener(MouseEvent.CLICK, ClickHandler);
removeEventListener(Event.ADDED_TO_STAGE, init);
}
private function ClickHandler(e: MouseEvent): void
{
trace("e.target.name: " + e.target.name);
_btnSelected = e.target.name;
parent.removeChild(this);
}
public function get BtnClicked(): String
{
return _btnSelected;
}
public function set BtnClicked(_str: String): void
{
_btnSelected = _str;
}
}
}
The code in my FLA follows here:
var mc: TestDialog = new TestDialog();
addChild(mc);
//Here is my intention to do:
/*
if (btnClicked == ok_btn)
proceed();
*/
I will highly appreciate a help, with some added code, to resolve this issue.