·您当前的位置:首页 > 技术教程 > AS2与AS3技术 >

影片剪辑MC载入类 MovieClipLoader的使用

时间:2011-10-09 08:39CuPlayer.com
影片剪辑MC载入类 MovieClipLoader的使用,载入外部SWF与JPG文件状态

载入外部SWF与JPG文件状态
myMcLoader = new MovieClipLoader();
myMcLoader.loadClip("载入文件地址",“载入影片”);
取得目前载入文件的下载状态
this.createEmptyMovieClip("cLTarget", 1);
cLTarget._x = 100;
cLTarget._y = 150;
var cL = new MovieClipLoader();
cL.loadClip("ball.swf", "cLTarget");
_root.onEnterFrame = function() {
bL = cL.getProgress.bytesLoaded;
bT = cL.getProgress.bytesTotal;
if (bL == bT) {
msg = "载入完成";
}
};
删除以MovieCliploader对象下载的影片剪辑对象
this.createEmptyMovieClip("cLTarget", 1);
cLTarget._x = 100;
cLTarget._y = 100;
var cL = new MovieClipLoader();
cL.loadClip("ball.swf", "cLTarget");
cLButton.onRelease = function() {
cL.unloadClip("cLTarget");
};
addListener指定MovieClipLoader对象的侦听对象
this.createEmptyMovieClip("cLTarget", 1);
cLTarget._x = 50;
cLTarget._y = 120;
var cL = new MovieClipLoader();
cL.loadClip("ball.swf", "cLTarget");
myListener = new Object();
myListener.onLoadStart = function() {
msgStart = "开始下载影片";
};
myListener.onLoadProgress = function() {
msgProgress = "影片下载中";
};
myListener.onLoadComplete = function() {
msgComplete = "影片下载完成";
};
myListener.onLoadInit = function() {
msgInit= "影片初始化";
};
myListener.onLoadError = function() {
msgError= "影片下载失败";
};
cL.addListener(myListener);
MovieClipLoader.removeListener删除MovieClipLoader对象的侦听对象MovieClipLoader.removeListener(listenerObj);
=========================================
载入图片与影片的进度
this.createEmptyMovieClip("mc",1);
mc._x = 0;
mc._y = 0;
var cl:MovieClipLoader = new MovieClipLoader();
cl.loadClip("2.jpg","mc");
var listener:Object = new Object;
listener.onLoadProgress = function(mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void{
_root.onEnterFrame = function(){
var a = bytesLoaded;
var b = bytesTotal;
text = Math.ceil(a/b*100)+"%"
trace(mc + ".onLoadProgress with " + bytesLoaded + " bytes of " + bytesTotal);
trace(text);
if(dl == dt){
txt = "OK"
}
}
}
cl.addListener(listener);
 

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器