ファイルで実行されているすべてのムービークリップを一時停止するボタンをFlashで作成しようとしています。これらのムービークリップはどれも私のメインタイムラインのトゥイーンではなく、すべて独自のタイムラインを持っています。各移動クリップは、クリップの再生を開始するように指示するボタンによってトリガーされます。ですから、誰かがこの一時停止ボタンの作成を手伝ってくれるなら、私はそれを大いに感謝します。お時間をいただきありがとうございます。
2234 次
4 に答える
3
Export your all symbols that you want to be paused/resumed recursively with a base class like this one, then you don't have to walk the entire display tree:
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();
}
}
}
}
于 2012-09-21T14:08:21.563 に答える
2
次のようにしてください。
// create an array to store all playing movieclips
var playing = [];
// when a movieclip is played add it to the array like this:
// playing.push(myMovieClip);
// call this from your pause button's click handler
function pauseAll()
{
// loop through all the playing movieclips ...
for (var i = 0; i < playing.length; i ++)
{
// ... and stop them
playing[i].stop();
}
// now clear the array
playing = [];
}
于 2012-06-13T23:28:36.527 に答える
0
私が知っているすべてのムービー クリップを一時停止する組み込みの方法はありません。
グローバルにアクセス可能なオブジェクトで一時停止するムービー クリップへの参照を保持している場合、一時停止を呼び出すこれらの参照を反復処理できます。
于 2012-06-13T20:35:23.340 に答える
0
この関数は、オブジェクトのネストされたすべての movieClip を停止します。ステージまたは最上位の表示クラスを渡すだけで、すべてを停止/再生できます。この方法では、配列への追加を追跡する必要がなく、オーバーヘッドもありません。
function recursiveStop(parentClip:DisplayObjectContainer, useStop:Boolean = true, gotoFrame:Object = null):void {
var tmpClip:MovieClip = parentClip as MovieClip;
if (tmpClip) {
if (useStop) {
(gotoFrame != null) ? tmpClip.gotoAndStop(gotoFrame) : tmpClip.stop();
}else {
(gotoFrame != null) ? tmpClip.gotoAndPlay(gotoFrame) : tmpClip.play();
}
}
var i:int = parentClip.numChildren;
while(i--){
if(parentClip.getChildAt(i) is DisplayObjectContainer){
recursiveStop(parentClip.getChildAt(i) as DisplayObjectContainer, useStop, gotoFrame);
}
}
}
于 2012-06-15T18:08:01.907 に答える