Skip to main content
Participant
August 17, 2018
Answered

in flash actionscript 3 how to stop imported .swf when hit backbutton ? plz hurry to answer my deadline is coming

  • August 17, 2018
  • 1 reply
  • 217 views

i use Flash cs 6 with action script 3

to import .swf i use this code but when i hit backbutton the video in sf file does not stop and still play on top of every thing

stop ();

var swfRequest:URLRequest = new URLRequest ("All clip 720p.swf");

var swfLoader:Loader = new Loader ();

    swfLoader.load (swfRequest);

  addChild (swfLoader);

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi.

    For your button code, you can write something like this:

    backButton.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void

    {

        swfLoader.unloadAndStop(true);

        removeChild(swfLoader);

        swfLoader = null;

    });

    The Loader class has this unloadAndStop method that tries to unload the SWF and stop code execution from it.

    It's also a good idea to remove the swfLoader object itself and set it to null to completely get rid of it and free up some memory.

    I hope this helps.

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    August 17, 2018

    Hi.

    For your button code, you can write something like this:

    backButton.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void

    {

        swfLoader.unloadAndStop(true);

        removeChild(swfLoader);

        swfLoader = null;

    });

    The Loader class has this unloadAndStop method that tries to unload the SWF and stop code execution from it.

    It's also a good idea to remove the swfLoader object itself and set it to null to completely get rid of it and free up some memory.

    I hope this helps.

    Regards,

    JC

    Participant
    August 17, 2018

    oh my god it work!!

    you are my saviour man.

    thank you thank you very much  ^____^

    JoãoCésar17023019
    Community Expert
    Community Expert
    August 17, 2018

    Excellent!

    You're welcome!