The Flash Player performs some operations at the end of the frame. The
Flash Player is on a loop of running code and then rendering to the screen.
Somewhere after it runs the code on the current frame it executes network
calls, decodes images, etc. Some of these are put on other threads so the
UI is not interrupted.
That's why you can add an event listener after you make a network call.
var request:URLRequest = new URLRequest("
http://www.google.com");
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.OPEN, function (event:Event)
{ trace('open') });
loader.load(request);
trace("load called");
var x:int = 10; // more code
trace(x);
loader.addEventListener(Event.OPEN, function (event:Event)
{ trace('open 2') });
// output
load called
10
open
open 2
If load actually did the network call at the time we called it the open
event would occur before our "load called" trace. But when we called load,
the trace message was output to the console and then after all the code in
the frame has run the network call is made and we receive the open and open
2 event.
So when you call System.pause() it will continue to run the remaining code
in the frame and pause on the next frame. In your case you might want to do
something like this:
if (someCondition) {
FlexGlobals.application.enabled = false; // disable mouse events -
interactions
System.pause();
return; // end code execution
}
// other code
Flash Player elastic race track:
http://www.craftymind.com/2008/04/18/updated-elastic-racetrack-for-flash-9-and-avm2/
http://help.adobe.com/en_US/as3/mobile/WS948100b6829bd5a61a52657a1274ff66899-8000.html
On Fri, Jun 27, 2014 at 8:30 AM, Raj U. Shaikh <[email protected]>
wrote:
> Hi,
> I am using Sytem.pause() to pause application, but this instruction didn't
> work immediately. (System.pause working but not immediately)
>
> For example if on click event listener function of a button I write
> following code,
>
> //Code start
> trace("Before pause");
> System.pause();
> trace("After pause");
> //Code end
>
> If I click first time on button following is output I can see on console,
>
> Before pause
> After pause
>
> If I went to click second time on button, then flash player will not allow
> me to click as everything is paused/halted.
>
> What will be required to stop the execution of flash player immediately so
> that I will not see second trace?
>
> I am using debug version of flash player.
>
> Any help please..
>
> Regards,
> Raj Shikh
> MASTEK LTD.
> In the US, we're called MAJESCOMASTEK
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Opinions expressed in this e-mail are those of the individual and not that
> of Mastek Limited, unless specifically indicated to that effect. Mastek
> Limited does not accept any responsibility or liability for it. This e-mail
> and attachments (if any) transmitted with it are confidential and/or
> privileged and solely for the use of the intended person or entity to which
> it is addressed. Any review, re-transmission, dissemination or other use of
> or taking of any action in reliance upon this information by persons or
> entities other than the intended recipient is prohibited. This e-mail and
> its attachments have been scanned for the presence of computer viruses. It
> is the responsibility of the recipient to run the virus check on e-mails
> and attachments before opening them. If you have received this e-mail in
> error, kindly delete this e-mail from desktop and server.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>