FLASH通过按钮加载外部SWF动画 的问题 80
是这样的,当FLASH播放完进入一个按钮选择界面,点击按钮,播放相应的小动画,小动画里有一个MENU按钮,点击后进入按钮选择界面。有些动画就没有任何问题,但是有些小SWF...
是这样的,当FLASH播放完进入一个按钮选择界面,点击按钮,播放相应的小动画,小动画里有一个MENU按钮,点击后进入按钮选择界面。
有些动画就没有任何问题,但是有些小SWF动画会出现MENU按钮报错无法返回的情况,这是为什么?
这是报错的参数:
Error: Error #2069: Loader 类不实现此方法。
at Error$/throwError()
at flash.display::Loader/removeChild()
at _fla::MainTimeline/backMc()
这是动画的AS:
/**
* 加载外部SWF动画
* @author Liuwen
*/
public class LoadSwf extends MovieClip
{
private var _loader:Loader;
private var _path:String;
private var _items:int;
public function LoadSwf() {
this.stop();
init();
}
private function init():void {
_loader = new Loader();
trace("###########*******************",totalFrames);
addFrameScript(this.totalFrames - 8, controlSwf);
}
/**
* 在动画最后一帧添加事件监听
*/
private function controlSwf():void {
this.stop();
_items = this.numChildren;
trace("###########*******************",_items);
for (var i:int = 0; i < _items; i++ ) {
if(this.getChildAt(i) is SimpleButton){
(this.getChildAt(i) as SimpleButton).addEventListener(MouseEvent.CLICK, onClickHandler);
}
}
}
/**
* 鼠标点击事件
*/
private function onClickHandler(e:MouseEvent):void {
var _name:String = e.target.name;
trace("###########*******************",_name);
var _swfName:String = _name.substr(4, _name.length);
_path = _swfName + ".swf";
trace("###########*******************",_path);
_loader.load(new URLRequest(_path));
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
_loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorEventHandler);
_loader.addEventListener(Event.UNLOAD, recyle);
}
private function completeHandler(e:Event):void {
//trace("###########");
this.addChild(_loader);
}
private function ioErrorEventHandler(e:IOErrorEvent):void {
try {
}
catch(e:Error){}
}
private function recyle(e:Event):void {
try{
_items = this.numChildren;
for (var i:int = 0; i < _items; i++ ) {
(this.getChildAt(i) as SimpleButton).removeEventListener(MouseEvent.CLICK, onClickHandler);
}
_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeHandler);
_loader.removeEventListener(IOErrorEvent.IO_ERROR, ioErrorEventHandler);
}
catch(e:Error){}
}
}
}
请大家帮我看看 3Q了~ 展开
有些动画就没有任何问题,但是有些小SWF动画会出现MENU按钮报错无法返回的情况,这是为什么?
这是报错的参数:
Error: Error #2069: Loader 类不实现此方法。
at Error$/throwError()
at flash.display::Loader/removeChild()
at _fla::MainTimeline/backMc()
这是动画的AS:
/**
* 加载外部SWF动画
* @author Liuwen
*/
public class LoadSwf extends MovieClip
{
private var _loader:Loader;
private var _path:String;
private var _items:int;
public function LoadSwf() {
this.stop();
init();
}
private function init():void {
_loader = new Loader();
trace("###########*******************",totalFrames);
addFrameScript(this.totalFrames - 8, controlSwf);
}
/**
* 在动画最后一帧添加事件监听
*/
private function controlSwf():void {
this.stop();
_items = this.numChildren;
trace("###########*******************",_items);
for (var i:int = 0; i < _items; i++ ) {
if(this.getChildAt(i) is SimpleButton){
(this.getChildAt(i) as SimpleButton).addEventListener(MouseEvent.CLICK, onClickHandler);
}
}
}
/**
* 鼠标点击事件
*/
private function onClickHandler(e:MouseEvent):void {
var _name:String = e.target.name;
trace("###########*******************",_name);
var _swfName:String = _name.substr(4, _name.length);
_path = _swfName + ".swf";
trace("###########*******************",_path);
_loader.load(new URLRequest(_path));
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
_loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorEventHandler);
_loader.addEventListener(Event.UNLOAD, recyle);
}
private function completeHandler(e:Event):void {
//trace("###########");
this.addChild(_loader);
}
private function ioErrorEventHandler(e:IOErrorEvent):void {
try {
}
catch(e:Error){}
}
private function recyle(e:Event):void {
try{
_items = this.numChildren;
for (var i:int = 0; i < _items; i++ ) {
(this.getChildAt(i) as SimpleButton).removeEventListener(MouseEvent.CLICK, onClickHandler);
}
_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeHandler);
_loader.removeEventListener(IOErrorEvent.IO_ERROR, ioErrorEventHandler);
}
catch(e:Error){}
}
}
}
请大家帮我看看 3Q了~ 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询