Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash 访问未定义的属性时发生错误1120_Flash_Actionscript 3_Timer - Fatal编程技术网

Flash 访问未定义的属性时发生错误1120

Flash 访问未定义的属性时发生错误1120,flash,actionscript-3,timer,Flash,Actionscript 3,Timer,这不是典型的1120。我知道最好不要在时间线上有没有实例名称的按钮/MC 不,这个问题存在于我根据在线找到的脚本构建的I计时器中。undefined属性与我要实现的计时器类delay相关 我试图实现的是让用户单击“下一步”按钮,等待1秒钟,然后滚动浏览下一个内容。我将代码放在条件语句中以减少代码量 需要注意的一点是,我正在使用TweenLite进行转换,如果这有什么区别的话 现在,下面的代码将显示计时器仅在下一个位置工作。我希望最终将其添加到剩余的下一个位置和所有以前的位置,以便在滚动内容时有一

这不是典型的1120。我知道最好不要在时间线上有没有实例名称的按钮/MC

不,这个问题存在于我根据在线找到的脚本构建的I计时器中。undefined属性与我要实现的计时器类delay相关

我试图实现的是让用户单击“下一步”按钮,等待1秒钟,然后滚动浏览下一个内容。我将代码放在条件语句中以减少代码量

需要注意的一点是,我正在使用TweenLite进行转换,如果这有什么区别的话

现在,下面的代码将显示计时器仅在下一个位置工作。我希望最终将其添加到剩余的下一个位置和所有以前的位置,以便在滚动内容时有一点延迟

此外,我希望重用相同的代码,以便当用户到达特定位置时,会有轻微的延迟和加载,和/或使图像或文本可见

我如何解决最初的问题,然后简化代码以在整个项目中重用代码

提前谢谢你的帮助

import gs.TweenLite;
import gs.easing.*;

var timer:Timer = new Timer(1500, 1);

next_mc.addEventListener(MouseEvent.CLICK, nextListener);
prev_mc.addEventListener(MouseEvent.CLICK, prevListener);
timer.addEventListener(TimerEvent.TIMER, delay); //I get the error here with "delay" 

prev_mc.visible = false;

function nextListener(event:MouseEvent):void {

 if (this.content_mc.slider_mc.x == 0) {

  function delay(event:TimerEvent):void {
   TweenLite.to(this.content_mc.slider_mc, 1, {x:-923.2, y:0, ease:Quart.easeInOut});
   prev_mc.visible = true;
  }
 } else {
  TweenLite.to(this.content_mc.slider_mc, 1, {x:-1872, y:0, ease:Quart.easeInOut});
  next_mc.visible = false;
 }
}

function prevListener(event:MouseEvent):void {
 if (this.content_mc.slider_mc.x == -1872) {
  TweenLite.to(this.content_mc.slider_mc, 1, {x:-923.2, y:0, ease:Quart.easeInOut});
  next_mc.visible = true;
 } else {
  TweenLite.to(this.content_mc.slider_mc, 1, {x:0, y:0, ease:Quart.easeInOut});
  prev_mc.visible = false;
 }
}

next_mc.buttonMode = true;
prev_mc.buttonMode = true;

timer.start();

问题是“delay”函数是在nextListener函数中定义的,因此在
timer.addEventListener(TimerEvent.timer,delay)中无法访问该函数代码。我想你是想把timer.addEventListener(TimerEvent.timer,delay)
移到下一个按钮处理程序中。

这是一个范围问题。您正在从此行调用“延迟”函数:

timer.addEventListener(TimerEvent.TIMER, delay); //I get the error here with "delay" 
但是延迟函数是在另一个函数nextListener中定义的

这意味着该行无法看到延迟功能。要解决此问题,只需将此行放在nextListener函数中:

function nextListener(event:MouseEvent):void {
// newly added ---v
timer.addEventListener(TimerEvent.TIMER, delay); //I get the error here with "delay" 
// rest of code
}