0
simple preLoader question
New Here
,
/t5/animate-discussions/simple-preloader-question/td-p/478396
Jan 11, 2008
Jan 11, 2008
Copy link to clipboard
Copied
Hi everyone
I found a good preloader code online and is working fine. RIght now the AS is showing the bytes loaded and I want it to show the simply the a double digit percentage. For example, I want it to say 79% loaded. I have tried dividing, multiplying and everything else. if you could help please let me know.
Here is my Code
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.text.TextField;
import flash.net.URLRequest;
var myLoader:Loader = new Loader();
var myRequest:URLRequest = new URLRequest("gallery.swf");
myLoader.load(myRequest);
myLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showLoadResult);
var loadProgress_txt:TextField = new TextField();
function showPreloader(event:Event):void
{
addChild(loadProgress_txt);
}
function showProgress(event:ProgressEvent):void
{
loadProgress_txt.text ="loading " + event.bytesLoaded + "total " + event.bytesTotal;
}
function showLoadResult(event:Event):void
{
removeChild(loadProgress_txt);
myLoader.x = 50
myLoader.y = 100
addChild(myLoader)
}
Thanks in advance
Ryan
I found a good preloader code online and is working fine. RIght now the AS is showing the bytes loaded and I want it to show the simply the a double digit percentage. For example, I want it to say 79% loaded. I have tried dividing, multiplying and everything else. if you could help please let me know.
Here is my Code
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.text.TextField;
import flash.net.URLRequest;
var myLoader:Loader = new Loader();
var myRequest:URLRequest = new URLRequest("gallery.swf");
myLoader.load(myRequest);
myLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showLoadResult);
var loadProgress_txt:TextField = new TextField();
function showPreloader(event:Event):void
{
addChild(loadProgress_txt);
}
function showProgress(event:ProgressEvent):void
{
loadProgress_txt.text ="loading " + event.bytesLoaded + "total " + event.bytesTotal;
}
function showLoadResult(event:Event):void
{
removeChild(loadProgress_txt);
myLoader.x = 50
myLoader.y = 100
addChild(myLoader)
}
Thanks in advance
Ryan
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advisor
,
LATEST
/t5/animate-discussions/simple-preloader-question/m-p/478397#M13798
Jan 11, 2008
Jan 11, 2008
Copy link to clipboard
Copied
you want to divide bytesLoaded into bytesTotal, multiply by
100 and then get the absolute value. like so:
var loadedPercentage:int=Math.floor((event.bytesLoaded/event.bytesTotal)*100);
var loadedPercentage:int=Math.floor((event.bytesLoaded/event.bytesTotal)*100);
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

