Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AS1/AS2 to AS3 onClipEvent(load),onClipEvent(enterFrame)

Explorer ,
Jul 01, 2011 Jul 01, 2011

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

TOPICS
ActionScript
12.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , Jul 01, 2011 Jul 01, 2011
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);
    }
}
Translate
Mentor ,
Jul 01, 2011 Jul 01, 2011
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);
    }
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 01, 2011 Jul 01, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 01, 2011 Jul 01, 2011

Yeah you can see using simulate download on player:

1.JPG

use the download settings to see with different bandwidths.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 01, 2011 Jul 01, 2011

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 01, 2011 Jul 01, 2011
LATEST

You'r welcome . No, only it shows atleast a frame loaded.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines