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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
anti-download video publishing site? 6 621
flash cs6 4 350
Script to Delete registry entry based on Product name 6 178
can not get an online video to playback in Google Chrome 4 38
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

733 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