lundi 21 novembre 2016

AS3 loading bar freezing while loading

I have a main and a loader .swf in AS3. The main.swf takes a while to load, so I wanted an animated loader so the user knows the application hasn't frozen, however trying to add either a progress bar of the percentage loaded or very simple looping movieclip, they "stall" while the main.swf loads, appearing frozen.

How do you avoid this? I've tried a couple of different setups, including:

import flash.display.Loader;

var myLoader:Loader = new Loader();
var myRequest:URLRequest = new URLRequest("main.swf")


... and another I found recommended here (as3 loading screen) :

var loader:Loader = new Loader()

loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

loader.load(new URLRequest("main.swf"));

function onProgress(event:ProgressEvent):void
var percentageLoader:Number = event.bytesLoaded / event.bytesTotal;

function onComplete(event:Event):void
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);


How do I stop the loadbar freezing, defeating its own purpose?

Aucun commentaire:

Enregistrer un commentaire