问题:加载外部SWF后,加载器不能响应鼠标事件,也就是点击加载的SWF没响应。
原因:加载后加载器MovieClip的所有属性方法都被擦出,参考资料
解决方法:在加载器下建一个子MovieClip用于加载SWF文件,用加载器进行控制。
基本步骤如下:
- 用createEmptyMovieClip创建一个空的MovieClip
- 使用MovieClip的loadMovie或者MovieClipLoader的loadClip加载外部SWF
var my_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadError = function(target_mc:MovieClip, errorCode:String, status:Number) {
trace("Error loading image: "+errorCode+" ["+status+"]");
};
mclListener.onLoadStart = function(target_mc:MovieClip):Void {
trace("onLoadStart: "+target_mc);
};
mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
var numPercentLoaded:Number = numBytesLoaded/numBytesTotal*100;
trace("onLoadProgress: "+target_mc+" is "+numPercentLoaded+"%loaded");
};
mclListener.onLoadComplete = function(target_mc:MovieClip, status:Number):Void {
trace("onLoadComplete: "+target_mc);
};
mclListener.onLoadInit = function(target_mc:MovieClip):Void {
// stop playing movie clip after loaded
target_mc.stop();
}
my_mcl.addListener(mclListener);
var loader = createEmptyMovieClip("loader"+i, this.getNextHighestDepth());
loader.target = loader.createEmptyMovieClip("loaderL"+i+"target", _parent.getNextHighestDepth());
my_mcl.loadClip("swf file url",loader.target);
这样加载后就可以对loader添加鼠标响应等行为,比如
loader.onPress = loaderPress;
loader.onRollOver = loaderRollOver;
loader.onRollOut = loaderRollOut;
1 条评论:
貌似。。。你是帮GF写AS?伟大
发表评论