0

我已经阅读了有关此错误的几个线程,但无法应用它来弄清楚我的情况......

我的 Flash 文件是一个大约 5 秒的动画。然后,每一层的最后一个关键帧(第 133 帧)中都有一个按钮。我的 Flash 文件应该在最后一个关键帧上停止,您应该能够单击 6 个按钮中的任何一个来导航到我网站中的另一个 html 页面。

这是我已应用于按钮所在框架的动作脚本(在单独的图层上,请参见截图: http ://www.footprintsfamilyphoto.com/wp-content/themes/Footprints/images/flash_buttonissue.jpg

stop ();


function babieschildren(event:MouseEvent):void 
{ 
    trace("babies children method was called!!!");
    var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/babies-children"); 
    navigateToURL(targetURL, "_self"); 
}

bc_btn1.addEventListener(MouseEvent.CLICK, babieschildren);
bc_btn2.addEventListener(MouseEvent.CLICK, babieschildren);


function fams(event:MouseEvent):void 
{ 
    trace("families method was called!!!");
    var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/families"); 
    navigateToURL(targetURL, "_self"); 
}

f_btn1.addEventListener(MouseEvent.CLICK, fams);
f_btn2.addEventListener(MouseEvent.CLICK, fams);


function couplesweddings(event:MouseEvent):void 
{ 
    trace("couples weddings method was called!!!");
    var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/couples-weddings"); 
    navigateToURL(targetURL, "_self"); 
}

cw_btn1.addEventListener(MouseEvent.CLICK, couplesweddings);
cw_btn2.addEventListener(MouseEvent.CLICK, couplesweddings);

当我测试电影时,我在输出框中收到此错误:

TypeError:错误 #1009:无法访问空对象引用的属性或方法。

测试影片确实在适当的帧上停止,但按钮不执行任何操作(没有打开 URL,并且当在测试影片上单击按钮时,跟踪语句不会显示在输出框中)。

您可以在此处查看 .swf 文件:www.footprintsfamilyphoto.com/portfolio

我确信所有 6 个按钮确实存在于相应的帧(第 133 帧)中,所以我认为这不是导致 1009 错误的原因。

我还尝试一次删除三个 function/addEventListener 部分中的每一个并进行测试,但每次我仍然收到 1009 错误。如果我删除除“stop ()”行之外的所有操作脚本,则不会收到 1009 错误。

有任何想法吗??我对 Flash 很陌生,所以如果我还没有澄清我需要的东西,请告诉我!


更新:我觉得这与我的文件的构建而不是代码本身有关 - 如果有人对我可以在此处包含的更多屏幕截图/信息提出建议,这可能有助于揭示任何结构缺陷,让我知道,我会很高兴捕捉/发布它们。我只是不确定要寻找什么作为错误 1009 的来源?我已经确认并再次确认了我的实例名称...所有按钮都存在于操作脚本所在的同一帧中(第 133 帧)。我没有导入任何外部对象...

我们欢迎所有的建议!

4

3 回答 3

2

我遇到了完全相同的错误,我在这里读到了一些关于 swf 没有按时赶上按钮实例的内容,即使它在同一帧上,而且确实如此。

我只是在动作脚本之前将按钮扩展了 1 帧并开始工作!

于 2012-09-27T22:10:25.577 回答
0

我使用 CS3 重建了您的示例,至少对我而言,它按预期工作,并且您的代码看起来也正确。我唯一能想象的是,您的每个 KEYFRAME 上都没有实例名称(例如“bc_btn1”)时间线。

在这种情况下,我遇到了同样的错误..所以也许你应该检查一下。

问候

于 2010-06-06T13:28:18.217 回答
0

非常感谢您的回复!如果我有 CS3 的副本,考虑到 CS4 一直给我带来的头痛,我非常愿意恢复!

我最终将我的文件发送给朋友/flash guru 直接修复。在这里粘贴他的回复,以防对其他人有帮助!

老实说,我有点惊讶它对你这样做,特别是因为我可以毫无问题地从 Flash 创作环境运行程序 - 只有当你真正从外部启动 swf 时才会出现问题。

检查这些按钮实例时,您肯定走在正确的轨道上。似乎是因为按钮被添加到该框架中,大约在框架脚本应该运行的同时,它只是陷入了无序状态。所以它试图在程序知道它们存在之前调用按钮上的 addEventListener 。

我不能说我的解决方案是否正确,但它应该可以工作并且相对较快。当程序到达该帧时,我会检查以确保每个按钮都存在。我将此检查放在由 ENTER_FRAME 事件调用的函数中,只要程序正在运行,它就会以程序的帧速率连续发生(这与我们正在调用的 stop() 命令无关)。一旦检查通过,这意味着没有一个按钮为空,我为所有按钮添加事件侦听器并删除 ENTER_FRAME 的侦听器,以便此检查器方法停止运行。

这是我现在拥有的那个框架的代码。看看这是否有帮助 - 它现在对我有用。我现在将不得不多读一点,看看推荐什么技术来处理这个问题。

import flash.events.Event;

stop ();

//listen for the Flash player's ENTER_FRAME event...
this.addEventListener(Event.ENTER_FRAME, onEnterFrame, false);

//and call this checker function continually until all of the buttons are accounted for
function onEnterFrame(e:Event):void {
 if (bc_btn1 != null && bc_btn2 != null && f_btn1 != null && f_btn2 != null && cw_btn1 != null && cw_btn2 != null){
  bc_btn1.addEventListener(MouseEvent.CLICK, babieschildren);
  bc_btn2.addEventListener(MouseEvent.CLICK, babieschildren);

  f_btn1.addEventListener(MouseEvent.CLICK, fams);
  f_btn2.addEventListener(MouseEvent.CLICK, fams);

  cw_btn1.addEventListener(MouseEvent.CLICK, couplesweddings);
  cw_btn2.addEventListener(MouseEvent.CLICK, couplesweddings);

  //clean up the enter frame listener so that this function no longer gets called
  this.removeEventListener(Event.ENTER_FRAME, onEnterFrame, false);
 }
}



function babieschildren(event:MouseEvent):void 
{ 
    trace("babies children method was called!!!");
    var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/babies-children"); 
    navigateToURL(targetURL, "_self"); 
}


function fams(event:MouseEvent):void 
{ 
    trace("families method was called!!!");
    var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/families"); 
    navigateToURL(targetURL, "_self"); 
}


function couplesweddings(event:MouseEvent):void 
{ 
    trace("couples weddings method was called!!!");
    var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/couples-weddings"); 
    navigateToURL(targetURL, "_self"); 
}
于 2010-07-14T21:10:48.497 回答