mercredi 23 décembre 2015

load and unload external swf files from a BUTTON click

I have a huge problem to load and unload my swf external pages in the main container. I have 4 external files to load and each of them is linked to a button and i would like this button (when pressed to lead the correspondant swf external file inside the main container).

here is the code that i am using ... any idea?

var mcExt1:MovieClip;
var load:Loader = new Loader();
load.contentLoaderInfo.addEventListener(Event.COMPLETE, HomeLoaded);
load.load(new URLRequest("home.swf"));


function HomeLoaded(e:Event):void {
mcExt1 = MovieClip(load.contentLoaderInfo.content);
load.contentLoaderInfo.removeEventListener(Event.COMPLETE, HomeLoaded);
mcExt1.x = 0;
mcExt1.y = 95;
addChild(mcExt1);
}

home_btn.addEventListener(MouseEvent.CLICK, loadhome);
function loadhome(e:MouseEvent):void {

    removeChild (mcExt1);
    mcExt1= MovieClip(load.contentLoaderInfo.content);
    load.load(new URLRequest("home.swf"));
    addChild (mcExt1);
    mcExt1.x = 0;
    mcExt1.y = 95;

}   

aboutus_btn.addEventListener(MouseEvent.CLICK, loadaboutus);
function loadaboutus(e:MouseEvent):void {

    removeChild (mcExt1);
    mcExt1= MovieClip(load.contentLoaderInfo.content);
    load.load(new URLRequest("aboutus2.swf"));
    addChild (mcExt1);
    mcExt1.x = 0;
    mcExt1.y = 95;

}   


getinvolved_btn.addEventListener(MouseEvent.CLICK, loadgetinvolved);
function loadgetinvolved(e:MouseEvent):void {

    removeChild (mcExt1);
    mcExt1= MovieClip(load.contentLoaderInfo.content);
    load.load(new URLRequest("getinvolved.swf"));
    addChild (mcExt1);
    mcExt1.x = 0;
    mcExt1.y = 95;

}   

contact_btn.addEventListener(MouseEvent.CLICK, loadcontact);
function loadcontact(e:MouseEvent):void {

    removeChild (mcExt1);
    mcExt1= MovieClip(load.contentLoaderInfo.content);
    load.load(new URLRequest("contact.swf"));
    addChild (mcExt1);
    mcExt1.x = 0;
    mcExt1.y = 95;

}



`   

THANKS A LOT IN ADVANCE !!

Aucun commentaire:

Enregistrer un commentaire