A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Simple loading/unloading .swf with embedded .flv via buttons

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Location
    Dallas, TX
    Posts
    7

    Simple loading/unloading .swf with embedded .flv via buttons

    Greetings
    I have created a simple flash file that loads 3 different external .swf's via the buttons that I created. These external .swf's load up with no problem but after I click the another button that relative .swf loads up on top of the other one or atleast the sound from the previous .swf is still playing. My question is, what is the easiest way to unload the current .swf entirely as I load the next one? I have attached my file.
    Thanks!!!

  2. #2
    Junior Member
    Join Date
    Jul 2008
    Location
    Dallas, TX
    Posts
    7
    sorry
    the file exceeded the limit so I cannot attach what I needed to.

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Unfortunately unloading does not work because of a bug, but you can delete the Loader and create a new one.
    - The right of the People to create Flash movies shall not be infringed. -

  4. #4
    Junior Member
    Join Date
    Jul 2008
    Location
    Dallas, TX
    Posts
    7

    thanks

    What exactly do you mean delete the loader and create a new one. Is that within the script?
    I have one content key frame with a container and three buttons on the stage. Then a key frame with the actionscript.
    Here is my script:

    var myLoader:Loader = new Loader();
    container.addChild(myLoader);

    one_bt.addEventListener(MouseEvent.CLICK, btn1Clicked);
    function btn1Clicked(event:MouseEvent):void
    {
    var myURL:URLRequest = new URLRequest("movie.swf");
    myLoader.load(myURL);
    }

    two_bt.addEventListener(MouseEvent.CLICK, btn2Clicked);
    function btn2Clicked(event:MouseEvent):void
    {
    var myURL:URLRequest = new URLRequest("movietwo.swf");
    myLoader.load(myURL);
    }

    three_bt.addEventListener(MouseEvent.CLICK, btn3Clicked);
    function btn3Clicked(event:MouseEvent):void
    {
    var myURL:URLRequest = new URLRequest("moviethree.swf");
    myLoader.load(myURL);
    }

  5. #5
    Senior Member
    Join Date
    Apr 2008
    Location
    Nottingham, UK
    Posts
    348
    I think he means:
    Code:
    delete loader;
    var loader:Loader = new Loader();
    or

    Code:
    loader = null;
    var loader:Loader = new Loader();

    Dan

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Thanks dan_hin

    To delete the Loader object use removeChild(loader)

    if(loader!=null)
    {
    removeChild(loader);
    var loader:Loader = new Loader();
    addChild(loader);
    }
    else
    {
    loader.load(request);
    }

    Something like this.

    Otherwise actually if you have a loader and load something new it should replace the old movie or image. just do not create new loaders to have several loaders.
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Junior Member
    Join Date
    Jul 2008
    Location
    Dallas, TX
    Posts
    7

    Thanks

    Thanks guys... y'all are very helpful. I understand that the one container that I have on the stage has to be either deleted or unloaded and then loaded again. I added the code to the end of my script and messed with it a bit but it received errors and I could not figure out exactly how I'm supposed to use it. Do I need to remove some previous script or edit the script that you gave me to some change.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center