Skip to main content
Participant
October 17, 2012
Question

AS3 and Timeline

  • October 17, 2012
  • 1 reply
  • 432 views

envrionment: FlashPro CS6 (12.0.0.481) on Windows 7

This might be a bit of a newbie question, but I am struggling to understand how I can more efficiently load and display external swf to the stage without using the timeline.

I have created 4 external swfs that load dynamic data from XML, assignes them to variables and then displays the data.

(RMStats.swf)

var xmlData:XML = new XML();
var theURL_ur:URLRequest = new URLRequest("RMStats.xml");
var loader_ul:URLLoader = new URLLoader(theURL_ur);
loader_ul.addEventListener("complete", fileLoaded);

function fileLoaded(e:Event):void
{
   xmlData = XML(loader_ul.data);
  
   RMDates_txt.text = xmlData.Dates;
   RMLostTime_txt.text = xmlData.LostTime;
   RMModifiedWork_txt.text = xmlData.ModifiedWork;
   RMMedicalAid_txt.text = xmlData.MedicalAid;
   RMFirstAid_txt.text = xmlData.FirstAid;
   RMIncidents_txt.text = xmlData.Incidents;
}

then I created a swf to load each of the individual swfs in sequence,

(movie.swf)

var myLoader:Loader = new Loader();

var url:URLRequest = new URLRequest("RMStats.swf");

myLoader.load(url);

addChild(myLoader);

but I find it cumbersome that the only way I can find to sequence the swfs is to create a timeline and call each from the actionscript at the beginning.

I looked for code snippets from others that have done this but couldn't find anything specific.

Is there any way to create one AS3 procedure that loads each external swf, waits the equivalivent of the time on the time line and then loops to the next?

In essence, can I replace the timeline with AS3?

example

var myLoader:Loader = new Loader();

var url:URLRequest = new URLRequest("RMCurrent.swf");

myLoader.load(url);

addChild(myLoader);

wait(60):

var my2ndLoader:Loader = new Loader();

var url2:URLRequest = new URLRequest("RMPrevious.swf");

my2ndLoader.load(url2);

addChild(my2ndLoader);

wait(60):

etc

I would probably create an array of the swf and call them in a loop if i could.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
October 17, 2012

you can either use a callback function in the last frame of your external swfs (that triggers the load and/or display of the next swf) or use an enterframe loop that repeatedly checks the currentFrame of the current swf and triggers the load/display of the next swf when currentFrame==totalFrames of the current swf.