Skip to main content
Participating Frequently
June 24, 2011
Question

Loading and Unloading External Swfs when clicking Forward and Back?

  • June 24, 2011
  • 2 replies
  • 1047 views

I am creating an interactive slideshow, like a PowerPoint effect, I have a main scene, 4 Buttons, a Home Button, Play Button, Forward Button & Back Button.

I want the Home Button to take me back to the start of the scene, Forward Button to Load a External swf slide and when the Forward Button is clicked again to Unload External swf and load in the next swf slide, I also want the Back Button to do a similar thing!

I keep getting External Swf pile-ups or flickering

Here's my code:

Play_button1.addEventListener(MouseEvent.CLICK, Play_btn1);

import fl.display.ProLoader;

var fl_ProLoader:ProLoader;

var fl_ToLoad:Boolean = true;

function Play_btn1(event:MouseEvent):void

{

        fl_ProLoader = new ProLoader();

        fl_ProLoader.load(new URLRequest("slides/slide1.swf"));

        addChild(fl_ProLoader);

        fl_ProLoader .y = 36;

    }

    else

    {

        fl_ProLoader.unload();

        removeChild(fl_ProLoader);

        fl_ProLoader = null;

    }

    // Toggle whether you want to load or unload the SWF

    fl_ToLoad = !fl_ToLoad;

}

Forward_button1.addEventListener(MouseEvent.CLICK, Forward_btn1);


function Forward_btn1(event:MouseEvent):void
{
    gotoAndStop("Slide2");
}

Back_button1.addEventListener(MouseEvent.CLICK, Back_btn1);
function Back_btn1(event:MouseEvent):void
{
    gotoAndStop("Home");
}

Home_button1.addEventListener(MouseEvent.CLICK, Home_btn1);
function Home_btn1(event:MouseEvent):void
{
    gotoAndStop("Home");
}

I hope this all makes sense, any Help will be useful. Thanks
This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
June 24, 2011

if you're publishing for fp10+, use:


Play_button1.addEventListener(MouseEvent.CLICK, Play_btn1);

import flash.display.Loader;

var fl_ProLoader:Loader=new Loader();

   addChild(fl_ProLoader);

        fl_ProLoader .y = 36;

var fl_ToLoad:Boolean = true;

function Play_btn1(event:MouseEvent):void

{

        //fl_ProLoader = new ProLoader();

        fl_ProLoader.load(new URLRequest("slides/slide1.swf"));

      //  addChild(fl_ProLoader);

        //fl_ProLoader .y = 36;

    }

    else

    {

       unloadF();

        //removeChild(fl_ProLoader);

      //fl_ProLoader = null;

    }

    // Toggle whether you want to load or unload the SWF

    fl_ToLoad = !fl_ToLoad;

}

Forward_button1.addEventListener(MouseEvent.CLICK, Forward_btn1);


function Forward_btn1(event:MouseEvent):void
{
unloadF()
    gotoAndStop("Slide2");
}

Back_button1.addEventListener(MouseEvent.CLICK, Back_btn1);
function Back_btn1(event:MouseEvent):void
{
unloadF()
    gotoAndStop("Home");
}

Home_button1.addEventListener(MouseEvent.CLICK, Home_btn1);
function Home_btn1(event:MouseEvent):void
{
unloadF()
    gotoAndStop("Home");
}

function unloadF():void{
if(fl_ProLoader.content){
fl_ProLoader.unloadAndStop();
}
}
kglad
Community Expert
Community Expert
June 24, 2011

unless someone's familiar with your ProLoader class, you're not going to get much help.

why are you using that instead of the flash Loader class?

DigikingAuthor
Participating Frequently
June 24, 2011

flash Loader class? Please explain more, I'm open to suggestions to achieving the same effect in a different way!