Solved

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

Posted on 2013-05-23
1
288 Views
Last Modified: 2013-06-07
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
Comment
Question by:msjlogicjunction
1 Comment
 
LVL 8

Accepted Solution

by:
section25 earned 300 total points
ID: 39192342
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now