Jump to content
Search Community
jguru test
Moderator Tag

Recommended Posts

Ok, I am pretty new to this flash / actionscript so please help me get on track...

 

I am trying to do the following:

 

FirstSwf -- contains a timelinemax that animates a text from left to right

 

SecondSwf -- contains a X number of photos that fade in and fade out with Y animation duration (number of images is dynamically parsed via XML configuration)

 

ThirdSwf -- contains a timeline that animates a text from bottom to top (sort of like credits screen)

 

Main.swf -- This is where I am stuck. I want to load the three SWF's into a master timeline inside main.swf and than sequentially play them one by one. I am able to load these swf's using LoaderMax but I can't seem to figure out two things:

 

1. How do I play them in sequence?

2. How do I control the sub timelines (within these external swf's) via the master timeline?

 

Any help would be appreciated!

 

Thanks

Link to comment
Share on other sites

Hi jguru,

 

Welcome to the GreenSock forums. First I'd like to congratulate you on your success so far with LoaderMax. That's quite a bit you have accomplished so far.

 

Second, thanks for the very clear question. Very interesting task you are trying to accomplish. Fret not, its totally possible.

 

I created a set of files that should help you see how this is done.

 

Each loaded swf (extTimeline1.swf, extTimeline2.swf, extTimeline3.swf) has a very simple TimelineLite that looks like this:

 

import com.greensock.*;

var tl:TimelineLite = new TimelineLite();
tl.append(TweenLite.to(mc, 1, {x:150}));

 

The swf that does all the loading (loadExtTimeline.swf) has this code:

 

import com.greensock.*;
import com.greensock.loading.LoaderMax;
import com.greensock.loading.SWFLoader;
import com.greensock.events.LoaderEvent;
import flash.events.MouseEvent;

// build a LoaderMax with a few SWFLoaders
// setting maxConnections:1 assures that all swfs load in sequence AND get added to the timeline in the right order
var myQueue:LoaderMax = new LoaderMax({onComplete:onCompleteHandler, maxConnections:1, onChildComplete:onChildCompleteHandler});
myQueue.append(new SWFLoader("extTimeline1.swf", {container:this}));
myQueue.append(new SWFLoader("extTimeline2.swf", {container:this, y:100}));
myQueue.append(new SWFLoader("extTimeline3.swf", {container:this, y:200}));

myQueue.load();

//Create a timeline to store all of the loaded timelines
var masterTimeline:TimelineLite = new TimelineLite({paused:true})

//when each swf loads grab its timeline (tl) and append it to the master timeline
function onChildCompleteHandler(e:LoaderEvent):void{
var loadedTimeline:TimelineLite = e.target.rawContent.tl
masterTimeline.append(loadedTimeline);
}

//when ALL swfs are done loading play the animation
function onCompleteHandler(e:LoaderEvent):void{
trace("all swfs loaded");
masterTimeline.play();
}

// control

play_btn.addEventListener(MouseEvent.CLICK, playClick);
pause_btn.addEventListener(MouseEvent.CLICK, pauseClick);
reverse_btn.addEventListener(MouseEvent.CLICK, reverseClick);

function playClick(e:MouseEvent):void{
masterTimeline.play();
}

function pauseClick(e:MouseEvent):void{
masterTimeline.pause();
}

function reverseClick(e:MouseEvent):void{
masterTimeline.reverse();
}

 

You can view it in action here: http://snorkl.tv/dev...ernalTimelines/

 

I have attached a set of CS5 fla files

 

Hopefully this helps

 

Happy Loading!

 

Carl

loadExternalTimelines_CS5.zip

Link to comment
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.
×
×
  • Create New...