AS3 - How to do a synchronous load of an asynchronous call?

前端 未结 4 829
小鲜肉
小鲜肉 2020-12-21 22:52

I have a function that loads a user object from a web service asynchronously.

I wrap this function call in another function and make it synchronous.

For exam

4条回答
  •  时光说笑
    2020-12-21 23:22

    The AS3 port of the PureMVC framework has mechanisms for implementing synchronous operations in a Model-View-Controller context. It doesn't try to synchronize asynchronous calls, but it lets you add a synchronous application pattern for controlling them.

    Here's an example implementation: PureMVC AS3 Sequential Demo.

    In this example, five subcommands are run sequentially, together composing a whole command. In your example, you would implement getUser() as a command, which would call commandComplete() in the getURL() (or whatever) callback. This means the next command would be certain that the getUser() operation is finished.

提交回复
热议问题