gpt4 book ai didi

flash - 如何在 Flash CS5 中制作通用暂停按钮?

转载 作者:行者123 更新时间:2023-12-05 01:26:54 25 4
gpt4 key购买 nike

我正在尝试在 Flash 中制作一个按钮,暂停在我的文件中运行的所有影片剪辑。这些影片剪辑都不是我的主时间线中的补间,它们都有自己的时间线。每个移动剪辑都由一个按钮触发,该按钮告诉剪辑开始播放。所以,如果有人能帮我创建这个暂停按钮,我将不胜感激。感谢您的时间。

最佳答案

使用像这样的基类递归地导出要暂停/恢复的所有符号,然后您不必遍历整个显示树:

package com.stackoverflow
{
import flash.display.MovieClip;
import flash.events.Event;

[Event(name="clipAdded", type="flash.events.Event")]
[Event(name="clipRemoved", type="flash.events.Event")]
public class BaseClip extends MovieClip
{
protected var baseClipChildren:Array;
protected var paused:Boolean = true;

public function BaseClip()
{
super();
baseClipChildren = new Array();
addEventListener(Event.ADDED_TO_STAGE, onAdded);
addEventListener("clipAdded", onClipAdded);
addEventListener(Event.REMOVED_FROM_STAGE, onRemoved);
addEventListener("clipRemoved", onClipRemoved);
}

protected function onAdded(event:Event):void
{
var target:BaseClip = event.target as BaseClip;
if(target == this) {
dispatchEvent(new Event("clipAdded", true));
}
}

protected function onClipAdded(event:Event):void
{
var target:BaseClip = event.target as BaseClip;
if(target && target != this) {
event.stopImmediatePropagation();
baseClipChildren.push(target);
}
}

protected function onRemoved(event:Event):void
{
var target:BaseClip = event.target as BaseClip;
if(target == this) {
dispatchEvent(new Event("clipRemoved", true));
}
}

protected function onClipRemoved(event:Event):void
{
var target:BaseClip = event.target as BaseClip;
if(target && target != this) {
event.stopImmediatePropagation();
baseClipChildren.splice(baseClipChildren.indexOf(target),1);
}
}

public function stopAll():void {
stop();
for each(var clip:BaseClip in baseClipChildren) {
clip.stopAll();
}
}

public function playAll():void {
play();
for each(var clip:BaseClip in baseClipChildren) {
clip.playAll();
}
}
}
}

关于flash - 如何在 Flash CS5 中制作通用暂停按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11022556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com