Forcing Flex to update the screen?

前端 未结 6 1733
梦谈多话
梦谈多话 2021-01-05 05:28

This may be a bit of a beginners question, but I can\'t for the life of me figure it out.

I\'m using flex to develop a GUI for a large project, specifically a status

6条回答
  •  执笔经年
    2021-01-05 05:54

    Actionscript in Flash player, like Javascript in the browser, is pseudo-multithreaded. That is, they're single threaded, but they have multiple execution stacks. This means you can't "sleep" in a particular thread, but you can spawn a new execution stack that gets deferred until a later time. The flex way of doing this is the "callLater" function. You can also use the setTimeout/setInterval functions. Or you can use a timer object built into the flash player. Or even "ENTER_FRAME" event listener. All of these will essentially allow you to do what you need, if I'm correct about the cause of your problems.

    It sounds like you have one "thread" doing most of your work, never stopping to allow other execution stacks (threads*) to run.

    The problem could be what PeZ is saying, but if that doesn't help, you might want to try some deferred calls for worker classes. So your process might look like this now:

    1. Progress initialized.
    2. Do some work.
    3. Update progress bar to 12. (invalidate display list)
    4. setTimeout(doMoreWork, 100);
    5. Update progress bar to 52.

    (if your worker is a UIcomponent, you can use uicomp.callLater(...), otherwise, you need to use setTimeout/timers/enter_frame for pure AS3 classes).

提交回复
热议问题