Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.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
Actionscript 3 ActionScript3横幅鼠标悬停暂停_Actionscript 3 - Fatal编程技术网

Actionscript 3 ActionScript3横幅鼠标悬停暂停

Actionscript 3 ActionScript3横幅鼠标悬停暂停,actionscript-3,Actionscript 3,我想在ActionScript3/Adobe Flash中创建简单的移动横幅。横幅由多个图像组成 我的代码在1里面。滑动和1.0帧 img1.addEventListener(MouseEvent.ROLL_OVER, thumb1RollOver, false, 0, true); img1.addEventListener(MouseEvent.ROLL_OUT, thumb1RollOut, false, 0, true); img2.addEventListener(MouseEven

我想在ActionScript3/Adobe Flash中创建简单的移动横幅。横幅由多个图像组成

我的代码在1里面。滑动和1.0帧

img1.addEventListener(MouseEvent.ROLL_OVER, thumb1RollOver, false, 0, true);
img1.addEventListener(MouseEvent.ROLL_OUT, thumb1RollOut, false, 0, true);

img2.addEventListener(MouseEvent.ROLL_OVER, thumb2RollOver, false, 0, true);
img2.addEventListener(MouseEvent.ROLL_OUT, thumb2RollOut, false, 0, true);

img3.addEventListener(MouseEvent.ROLL_OVER, thumb3RollOver, false, 0, true);
img3.addEventListener(MouseEvent.ROLL_OUT, thumb3RollOut, false, 0, true);

img5.addEventListener(MouseEvent.ROLL_OVER, thumb5RollOver, false, 0, true);
img5.addEventListener(MouseEvent.ROLL_OUT, thumb5RollOut, false, 0, true);



function thumb1RollOver(e:MouseEvent):void
{
    this.stop();
}

function thumb1RollOut(e:MouseEvent):void
{
    this.play();
}

function thumb2RollOver(e:MouseEvent):void
{
    this.stop();
}

function thumb2RollOut(e:MouseEvent):void
{
    this.play();
}

function thumb3RollOver(e:MouseEvent):void
{
    this.stop();
}

function thumb3RollOut(e:MouseEvent):void
{
    this.play();
}

function thumb5RollOver(e:MouseEvent):void
{
    this.stop();
}

function thumb5RollOut(e:MouseEvent):void
{
    this.play();
}
这段代码工作得很好,但只适用于第一幅图像。鼠标悬停时电影停止,发行时继续。但对于进一步的幻灯片,它不起作用

我是否需要将每个幻灯片代码分开?但是再一次。当我这样做的时候,它根本没有播放电影

在输出屏幕上,我看到以下消息:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at banner_flash_fla::MainTimeline/frame1()

img2
img3
img5
在您的第一帧上不存在,这是您的类型错误的原因

您的movieclip的结构如下所示:

MovieClip
    frame1
        img1
    frame2
        img2
等等

如果您将所有这些代码放在第1帧上,它将无法工作。它只能看到
img1
,无法找到
img2
img3
img5
。因此出现了打字错误。请注意,如果安装调试播放机,您将能够看到行号,这将有助于跟踪任何未来的问题。不过,您可能必须构建调试版本才能使用调试播放器查看行号

考虑通过库向横幅添加一个类。我在这里找到了一个关于这个的教程:否则你可能可以通过谷歌搜索找到它

所以是的

我是否需要将每个幻灯片代码分开

是的,您可以。或者您需要给它一个类并动态附加图像