动态加载类;

      FLASH 2005-8-17 23:47
随便写了个.可加载图片或影片.主要是MovieClipLoader的应用.
代码你可以自己改成更附合你要的;
代码如下:

class Makepic extends MovieClip {
    var _mc, _image, _loading, _Loader, picListenner;
    var _pic, _height, maph, _yscale, _xscale, _width, _x, _y;
    function Makepic(mc, loader, image) {
        super();
        _mc = mc;
        _image = image;
        _loading = loader;
        _Loader = new MovieClipLoader();
        picListenner = new Object();
        this.createpic();
    }
    // End of the function
    function createpic() {
        var _l3 = this;
        _pic.removeMovieClip();
        _pic = _mc.createEmptyMovieClip("pic", _root.getNextHighestDepth());
        maph = _mc._parent.picMask._height;
        //这个宽度有在注意中;
        this.loading();
    }
    // End of the function
    function loading() {
        var _this = this;
        var h = 0;
        _Loader.unloadClip(_pic);
        _Loader.loadClip(_image, _pic);
        picListenner.onLoadStart = function(evt) {
            _this._loading._visible = true;
            //_xscale = _yscale=100;
        };
        // End of the function
        picListenner.onLoadProgress = function(mc, LoadBytes, TotalBytes) {
            _this._loading.loadText.text = (int(LoadBytes/TotalBytes*100)+"%").toString();
            trace(_this._loading.loadText.text);
        };
        // End of the function
        picListenner.onLoadComplete = function(evt) {
        };
        // End of the function
        picListenner.onLoadInit = function(evt) {
            _this._loading._visible = false;
            var t = evt._width/evt._height;
            evt._height = _this.maph;
            evt._width = t*_this.maph;
            evt._x = -evt._width/2;
            evt._y = -evt._height/2;
            trace(evt._yscale+","+_this.maph);
        };
        // End of the function
        picListenner.onLoadError = function(mc, errorcode) {
            trace(errorcode);
        };
        // End of the function
        _Loader.addListener(picListenner);
    }
    // End of the function
}
// End of Class
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commenttime}{commentauthor}

{CommentUrl}
{commentcontent}