Copy link to clipboard
Copied
onClipEvent (load) {
total = _root.getBytesTotal();
}
onClipEvent (enterFrame) {
loaded = _root.getBytesLoaded();
percent = int(loaded/total*100);
text = percent+"%";
gotoAndStop(percent);
if (loaded == total) {
_root.gotoAndPlay(2);
}
}
Dear all,
I found a sample code that is writen in AS1/AS2 to see if the load is finished, If finish loading, it will go to the next frame. How do I convent this into AS3? This is my first time looking at AS1/AS2 code, especially onClipEvent (load), _root.getBytesTotal(), onClipEvent (enterFrame), _root.getBytesLoaded(),_root.gotoAndPlay(2).
Can someone help me out with this?
Thanks,
-Zainuu
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void{
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
if (total == loaded){
play();
ploader.visible=false;
this.removeEventListener(Event.ENTER_FRAME, loading);
}
}
Copy link to clipboard
Copied
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void{
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
if (total == loaded){
play();
ploader.visible=false;
this.removeEventListener(Event.ENTER_FRAME, loading);
}
}
Copy link to clipboard
Copied
Hi, Thanks for the reply
stop();
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void{
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
trace(total);
trace(loaded);
if (total == loaded){
play();
mc_Loader.visible=false;
this.removeEventListener(Event.ENTER_FRAME, loading);
}
}
I tried to trace the total bytes and loaded bytes, it returns me
total = 405668
loaded = 405668
Is there a way to show the loaded bytes starting from 1 till 405668? I'm trying to find out if it is really loading the thing. Otherwise is there any other ways to slow down the loading for a bit because it only shows my loading bar for 0.5secs, not really sure if its really loading it...
Copy link to clipboard
Copied
Yeah you can see using simulate download on player:
use the download settings to see with different bandwidths.
Copy link to clipboard
Copied
Thanks, that's very helpful!
Btw why after I clicked the simulate download, the stage will turn white ( but my stage color is blue ). Does that matters at all?
Copy link to clipboard
Copied
You'r welcome . No, only it shows atleast a frame loaded.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now