【问题标题】:stop more than one object of same movieclip all at once in flash在 Flash 中一次停止同一影片剪辑的多个对象
【发布时间】:2014-01-26 11:21:50
【问题描述】:

在某个特定的时间差之后,我一遍又一遍地生成同一个影片剪辑的子级。在任何情况下,我都要求舞台上的所有电影剪辑立即暂停并在另一个间隔后再次播放。关于我该怎么做的任何建议?我正在使用 flash 专业 CS5.5 和 actionscript 3.0。

【问题讨论】:

    标签: actionscript-3 flash animation movieclip


    【解决方案1】:

    每次你生成一个新的孩子,把它推到一个数组中:

    var myArray:Array = new Array();
    function makeChildren() {
        var newChild:MovieClip = new originalMC();
        myArray.push(newChild);
        addChild(newChild);
    }
    

    然后,您可以随意访问所有生成的影片剪辑。 当您需要暂停或全部播放时,只需为每个循环运行一个:

    for each(var myVar in myArray) {
      myVar.pause(); // or myVar.play();
    } 
    

    听起来像你在寻找什么?

    【讨论】:

      【解决方案2】:

      如果您无法将所有对象保存在同一个数组中,您可以递归扫描显示列表并检查每个对象:

      function lookRecursively( target : DisplayObjectContainer ) : void
      {        
        for ( var i:int = 0, l:int = target.numChildren; i < l; i++ ) {
          var child:DisplayObject = target.getChildAt(i);
          if ( child is DisplayObjectContainer ) {
            if ( DisplayObjectContainer(child).numChildren > 0 ) {
              if ( child is SOME_OBJECT_CLASS_HERE ) {
                // do what you gotta do here...
              } else {
                lookRecursively( DisplayObjectContainer ( child ) );
              }
            }
          }
        }
      }  
      

      【讨论】:

        猜你喜欢
        • 2010-09-11
        • 1970-01-01
        • 2014-09-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-26
        • 2018-01-13
        • 1970-01-01
        相关资源
        最近更新 更多