Maxe

Why I'm Stupid ? (truly sorry for any inconvenience)

Recommended Posts

Hello Carl and eveybody ...

I found this project you uploaded named loadSWFsPlaySequence dot zip ...

but unfortunately I faced a big problem :

problem 1 :

as I want to load huge and multiple swfs one after another I should be aware of memory that loaded swfs take ,so I tried to unload last swf when new swf is loading but each time I failed ...

 

problem 2 : how can I fade in each swf that is loading using loadeMax ?

 

please somebody tell me am I such stupid or it's hard to ...

can you help ? 

thanks a lot ...

link to that file :

http://greensock.com/forums/index.php?app=core&module=attach&section=attach&attach_id=2074

Share this post


Link to post
Share on other sites

Wow. That's a demo I made 5 years ago.

 

We really don't support our Flash tools much anymore unless you find a bug.

to fade in the swfs you would just create a TweenLite tween on the content of the loader instead of just setting its visibile to true.

 

To unload() the previous swf is a little more involved but this should work:

 

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;


progress_mc.scaleX = 0;


var loaderIndex:Number = -1;
var currentLoader:SWFLoader;


var swfs:LoaderMax = new LoaderMax({onComplete:completeHandler,onProgress:progressHandler,onChildComplete:childCompleteHandler});


swfs.append(new SWFLoader("part1.swf", {container:container_mc, autoPlay:false}));
swfs.append(new SWFLoader("part2.swf", {container:container_mc, autoPlay:false}));
swfs.append(new SWFLoader("part3.swf", {container:container_mc, autoPlay:false}));
swfs.append(new SWFLoader("part4.swf", {container:container_mc, autoPlay:false}));


function progressHandler(e:LoaderEvent):void {
progress_mc.scaleX = e.target.progress;
}



function childCompleteHandler(e:LoaderEvent):void {
trace(e.target + " loaded");
e.target.content.visible = false;

}


function completeHandler(e:LoaderEvent):void {
trace("all swfs loaded");

progress_mc.visible = false;


initCurrentLoader();
addEventListener(Event.ENTER_FRAME, trackSWFPlayback);

}


function initCurrentLoader() {

    loaderIndex++; 


if (loaderIndex == swfs.numChildren) {
//reset back to 0 if the last swf has already played
//loaderIndex  =  0;


        //can't show stuff that was unloaded so lets stop 


trace("all done everyone gone");
removeEventListener(Event.ENTER_FRAME, trackSWFPlayback);




} else {
//dynamically reference current loader based on value of loaderIndex




currentLoader = swfs.getChildAt(loaderIndex);


//make the content of the current loader visible


currentLoader.content.visible = true;


    //fade it in 


TweenLite.from(currentLoader.content, 2, {alpha:0});


//tell the current loader's swf to to play


currentLoader.rawContent.gotoAndPlay(1);
}




}




function trackSWFPlayback(e:Event):void {
//trace(currentLoader.rawContent.currentFrame);


//detect if the loaded swf is on the last frame


if (currentLoader.rawContent.currentFrame == currentLoader.rawContent.totalFrames) {


trace("swf done");


//hide and stop current swf
currentLoader.content.visible = false;
        
currentLoader.rawContent.stop();

//unload the swf that just played 
        
currentLoader.unload();
        
//set up and play the next swf


initCurrentLoader();


}
}


load_btn.addEventListener(MouseEvent.CLICK, loadSWFs)


function loadSWFs(e:MouseEvent):void{
load_btn.visible = false;
swfs.load();
}

So that code will play through a swf, unload it, fade in the next one. When all swfs are done playing the whole things stops.

 

Hopefully that helps. Unfortunately that's about all I can do. 

Share this post


Link to post
Share on other sites

 

 

We really don't support our Flash tools much anymore unless you find a bug.
Unfortunately that's about all I can do. 

steel much more efficient than stackoverflow ...

no way to thank you for ...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.