影片剪辑不会停止总是循环 [英] movieClip not stopping always looping

查看:297
本文介绍了影片剪辑不会停止总是循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有得到一个影片剪辑的类,然后使用addChild将其添加到显示。问题是,我不能播放或停止它。基本上,我不能与MovieClip互动。

I have a class that gets a movieClip and then using addChild adds it to be displayed. Problem is that I cannot play or stop it at all. Basically I can't interact with the movieClip.

下面是code:

public function Avatar(movieClip:DisplayObject) //class constructor
{   ...
    avatarSprite = MovieClip(movieClip)
    addChild(avatarSprite);
    avatarSprite.gotoAndStop(1); //this is not working
    trace(avatarSprite.currentFrame) //always returns 1
    trace(avatarSprite.isPlaying) // returns false
    ...
    }

当我运行code中的动画片段起着一个循环,因为我希望它不会停止。我不知道什么问题。正如你所看到的我什么也没做太复杂。任何想法,我缺少在这里吗?

When I run the code the movieClip plays in a loop and doesn't stop as I expect it to. I am not sure what's the problem. As you can see I didn't do anything too complicated. Any idea what I am missing here please?

在此先感谢

编辑:作为miguelSantirso指出。问题是,在影片剪辑嵌套的动画,而不是C本身的实际$ C $。有谁知道如何停止的嵌套动画的播放?

As miguelSantirso pointed out. The problem is with the nested animations in the movieClip and not the actual code itself. Does anyone know how to stop nested animations from playing?

推荐答案

此功能将停止所有嵌套的MovieClip(或打他们,如果你传递false给useStop参数)

This function will stop all nested movieClips (or play them if you pass false to the useStop parameter)

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);
        }
    }
}

这篇关于影片剪辑不会停止总是循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆