A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: load/unload issue

  1. #1
    Junior Member
    Join Date
    Nov 2014
    Posts
    2

    load/unload issue

    Ok so I cannot figure out for the life of me how to accomplish this.

    I have my main SWF. It contains buttons. I am using the Proloader script from the snippets to load
    an external swf.

    This external SWF is a seperate window that pops up on top of everything in my main swf. The external swf itself has a button and I need that button to close itself, so that you can essentially load the external swf from the main page, and hit a little X button in the corner of that external SWF to close it.


    THIS works for the external swf by itself.

    Close_But.addEventListener (MouseEvent.CLICK, fl_unloadwin);

    function fl_unloadwin (event:MouseEvent):void {

    this.stop();
    this.parent.removeChild(this);
    }


    but it apparently doesnt work with the proloader script i used in the main SWF

    Start_Button.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);

    import fl.display.ProLoader;
    var fl_ProLoader:ProLoader;

    //This variable keeps track of whether you want to load or unload the SWF
    var fl_ToLoad:Boolean = true;

    function fl_ClickToLoadUnloadSWF(event:MouseEvent):void
    {
    if(fl_ToLoad)
    {
    fl_ProLoader = new ProLoader();
    fl_ProLoader.load(new URLRequest("NW_BG.swf"));
    addChild(fl_ProLoader);
    fl_ProLoader.x = 75;
    fl_ProLoader.y = 75;
    }
    else
    {
    fl_ProLoader.unload();
    removeChild(fl_ProLoader);
    fl_ProLoader = null;
    }
    // Toggle whether you want to load or unload the SWF
    fl_ToLoad = !fl_ToLoad;
    }


    I need to get this working in any way possible. This is for a class project and my teacher sucks so bad he is essentially useless. If someone could fix this for me, I would be so grateful.

    Thanks in advance.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    You should use fl_ProLoader.unloadAndStop(); instead of fl_ProLoader.unload();

    and simply add a listener to the close button in your external swf and call the load/unload function in this one.

    PHP Code:
    externalSWFCloseButton.addEventListener(MouseEvent.CLICKMovieClip(this.parent.parent).fl_ClickToLoadUnloadSWF); 

  3. #3
    Junior Member
    Join Date
    Nov 2014
    Posts
    2
    Wow, this works perfectly...you sir are a god among men. Thank you.

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