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
285 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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

772 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

10 Experts available now in Live!

Get 1:1 Help Now