Jump to content
Search Community

Looping multiple SWFs loaded from an XML file

Guest aezzell
Moderator Tag

Recommended Posts

Guest aezzell

With much help from these forums (http://forums.greens...7775#entry17775), I finally got a project running. A main movie loads some number of SWFs based on the contents of an XML file. The current application doesn't take advantage of the ability to select random SWFs from a set of SWFs, but that feature works.

 

Here's the page that uses this: http://us.gpstrategies.com/

 

It works like it was designed to work. The SWFs load, play through once, and stop. You can use the buttons at the bottom to jump to a specific clip, and each "story" clip has a link that takes you to a related location in our site.

 

But now... the marketing director wants to have this running in the background at our corporate booth at a a conference. She wants it to loop continuously.

 

I've figured out a (probably kludgey) way to make it loop correctly a specific number of times, but when I tried to a make an infinite do...while loop, of course it was unhappy.

 

I found an example on snorkl.tv (http://snorkl.tv/dev/loadPlaySwfs/), that does what I want it to do, but it relies on comparing the currentFrame to the totalFrames in the SWF being played, and all my loaded SWFs only have one frame, because they're all created using TweenMax and TimelineMax.

 

Here's the completeHandler that works if I specify a given number of repetitions:

function completeHandler(event:LoaderEvent):void
{
//hide the progress bar
progressAnimation.visible = false;
//stop the timer
t.stop();
//keep higher movies from blocking "Learn more..." links on lower movies
for (var j:Number = 1; j < hM + 1; j++)
{
 LoaderMax.getLoader("clip" + swfs[j].@id).rawContent.visible = false;
}
backgroundHolder.visible = true;
movieHolder.visible = true;
//load the intro immediately
runIt("clip" + swfs[1].@id,swfs[1].@id);
//show the nav bar;
nav_mc.visible = true;
TweenMax.to(nav_mc,2,{alpha:1});
var loopCtr:int = 1;
do
{
//then load the rest of the movies with the specified delay;
for (var k:Number = 2; k < hM + 1; k++)
{
 TweenMax.delayedCall(delayTime*loopCtr,runIt,["clip" + swfs[k].@id,swfs[k].@id,swfs[k-1].@id]);
}
//have to put the first clip in here so that it's included in the loop;
TweenMax.delayedCall(delayTime*loopCtr,runIt,["clip" + swfs[1].@id,swfs[1].@id,swfs[hM].@id]);
} while (loopCtr < 60);
}

The SWFs are all loaded into an array (swfs), each with an ID that's also loaded from the XML file, and each is given a name like clip01 or clip02 when it's appended to the LoaderMax.

 

The runIt function is:

function runIt(ldrName:String,secName:String,prevSecName:String=""):void
{
//show the clip being called
LoaderMax.getLoader(ldrName).rawContent.visible = true;
//hide the previous section if there is one
if (prevSecName != "")
{
LoaderMax.getLoader("clip" + prevSecName).rawContent.visible = false;
}
//hide the last clip if it's not being called
//this should probably be handled better - should only have to be hidden once each loop
//need to do this because when the loop re-starts, the last clip is not the previous clip
if (ldrName != lastClip)
{
LoaderMax.getLoader(lastClip).rawContent.visible = false;
}
LoaderMax.getLoader(ldrName).rawContent.runMovie();
activateCurrentSection(secName);
}

 

The activateCurrentSection function controls the colors of the navigation buttons and tracks the current section and the previous section for when the navigation buttons are active, so you can hide the one you just left and show the one you're going to.

 

Basically, what this code does is run the first SWF immediately, then each attached SWF in order with an appropriate delay, then it runs the first one again, then loops through the others, runs the first, loops through the others... 59 times.

 

But I want this to run continuously.

 

When I try setting the while to something that will always be true, I get:

Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
at usGPXMainLoop10_fla::MainTimeline/completeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.greensock.loading.core::LoaderCore/_completeHandler()
at com.greensock.loading::LoaderMax/_loadNext()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.greensock.loading.core::LoaderCore/_completeHandler()
at com.greensock.loading::SWFLoader/_completeHandler()

 

Suggestions?

 

Thanks!

Link to comment
Share on other sites

This looks like it's beyond the kind of help we provide here (which is typically just questions directly related to GreenSock tools), but let me ask you this: Can you provide a VERY concise bullet-point list of what exactly must happen? For example:

  1. Load an XML file that contains information about several swfs that should be subloaded
  2. Subload and display the swf sequentially. When the first one is done, the next one replaces it, then the next, etc.
  3. When the sequence ends, we loop back to the first one and play the sequence again (endless loop)

Does that summarize what you're trying to do?

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...