• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 320
  • Last Modified:

AS3 coding a loader for a swf so that the first scene will play while the others are still loading

Hi,
I have a loader for a 41MB swf that, at the moment makes the swf load in its entirety before it begins playing. I would like to change the code to allow the first scene to play as the others are continuing to download. Is this possible to do in the ActionScript?
My current code is:
var req:URLRequest = new URLRequest ("VirtualNurseDemo5D.swf");
var loader:Loader = new Loader ();

function fileLoaded(event:Event):void
{
	addChild(loader);
}

function preload(event:ProgressEvent):void
{
	var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
	loadertxt.text = String(percent) + "%";
	trace (percent);
}
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fileLoaded);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preload);
loader.load(req);

Open in new window




Thanks!
0
msjlogicjunction
Asked:
msjlogicjunction
1 Solution
 
section25Commented:
Unfortunately, a "swf" is not like a "flv". Since it is not a video, it needs to finish downloading so that all of the compenets are in place before flash can start using it.

Just imagine if the first frame of the loading swf calls a function that is in the last frame of the loading swf, what would happen when the function is called and it is not loaded yet? Big problem. So in order to prevent that, flash waits for the whole thing to finish loading before it allows it to be used. A video is different becuase it does not present the same problems. The first frames never depend on any other frames later in the movie.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now