| areostar |
01.10.2011 00:09 |
Кнопка не слышит событие
хочу что б в приложении можно было менять вид кнопок
из XML сё читаю порядок и кнопки появляются где надо!..
Только вот события не слышит(нажать на кнопку не получается! :blush: )
вот код вавода кнопок на экран:
Код AS3:
private function init_button()
{
var loadURL:URLRequest = new URLRequest(buttons_array[button_caunt * kind_button]);
var loader:Loader = new Loader();
loader.load(loadURL);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
}
function onLoadComplete(e:Event):void
{
e.currentTarget.removeEventListener(Event.COMPLETE, onLoadComplete);
var lmc:DisplayObject = e.target.content;// as DisplayObject;
if(button_caunt == 0)
{
pl_button = new SimpleButton(lmc);
pl_button.x = 122; pl_button.y = 462; stage.addChild(pl_button);
pl_button.addEventListener(MouseEvent.CLICK, pl_button_click);
}
if(button_caunt == 1)
{
p_button = new SimpleButton(lmc);
p_button.y = 462; p_button.x = 124; stage.addChild(p_button);
p_button.addEventListener(MouseEvent.CLICK, p_button_click);
}
.......................................
Кнопки обьявлены глобально:
Код AS3:
var p_button:SimpleButton;
var pl_button:SimpleButton;
Но события не срабатывают! почему!?
|