I have a method that I want to be enqueued to the UI thread message pump. How is this done in actionscript? Basically I am looking for the equivalent of Sys开发者_StackOverflowtem.Windows.Deployment.Current.Dispatcher.BeginInvoke() in actionscript.
All timing in the Flash Player eventually comes back to the frame rate.
Not knowing exactly what the windows API you mention does, I can only assume it sets up a method to be run at a later point (say when needed by the UI, or when the UI is about to refresh).
If that's the case then you can simply setup your method to be run on the next ENTER_FRAME or EXIT_FRAME event. In both cases you need a DisplayObject to tap into (the stage is fine). There is no built-in one-shot event subscription in AS3 at this time, so you'll need to have a stub method that runs the function you want run and then removes the event listener.
You can also instantiate a Sprite, store it in a member variable and attach the event listener to it. It does not need to be on the stage for it to receive the ENTER_FRAME event.
精彩评论