0

I have some issues with my preloader class. everytime I try to run the MovieClip it gives me 4 errors of 1120: access of undefined property e. I dont know what the problem is.

package {

import flash.display.MovieClip;
import flash.events.*;
import flash.text.*;

public class loadingScene extends MovieClip {

    public var percentLoad:Number = Math.round(e.bytesLoaded / e.bytesTotal * 100);

    public function loadingScene() {
        stop();
        this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
    }


    public function onProgress(e:ProgressEvent):void {
        loader_txt.text = Math.round(e.bytesLoaded / e.bytesTotal *100)+ "%";
        if (percentLoad == 100){
            onLoaded();
        }

    }

    function onLoaded() {
        this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
        trace("YES"); 
    }

}

}

4

1 回答 1

1

删除初始化 percentLoad 的位置。e 在那个时间点不存在,因此它是未定义的。您也没有在任何地方定义 e,但 MovieClip 认为您已经定义了。

import flash.display.MovieClip;
import flash.events.*;
import flash.text.*;

public class loadingScene extends MovieClip {

    public var percentLoad:Number = 0;

    public function loadingScene() {
        stop();
        this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
    }


    public function onProgress(e:ProgressEvent):void {
        percentLoad = Math.round(e.bytesLoaded / e.bytesTotal * 100);
        loader_txt.text = percentLoad+ "%";
        if (percentLoad == 100){
            onLoaded();
        }

    }

    function onLoaded() {
        this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
        trace("YES"); 
    }

}
于 2013-06-01T17:18:39.593 回答