简体   繁体   English

ADDED_TO_STAGE事件似乎没有像我想的那样工作

[英]ADDED_TO_STAGE event doesn't seem to work as I thought

I need to display a message for the user before a CPU hungry function starts. 我需要在CPU饥饿功能启动之前为用户显示一条消息。 I start that function after the ADDED_TO_STAGE event is fired but half of the time, message box doesn't have enough time to be displayed when that heavy function starts. 我在ADDED_TO_STAGE事件被触发后启动该函数但是有一半的时间,消息框没有足够的时间显示该重函数启动时。 Is there any other way to make sure a message box is displaying before a heavy function starts processing things? 有没有其他方法可以确保在重函数开始处理之前显示消息框?

Start heavy function in the next frame after popup window, use Event.ENTER_FRAME event for this. 在弹出窗口后的下一帧中启动重函数,为此使用Event.ENTER_FRAME事件。 AVM executes as3 code in the beginning of frame and render graphics at the end, so your code that shows the window executed, but graphics is rendered only after heavy function, eg: AVM在帧的开头执行as3代码并在结尾渲染图形,因此您的代码显示执行的窗口,但图形仅在重函数后呈现,例如:

protected function init():void
{
    showPopup();
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
}

private function onEnterFrame(event:Event):void
{
    removeEventListener(event.type, arguments.callee);
    startHeavyFunction()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM