javascript - 如何在 EaselJS 中获取影片剪辑的当前位置(帧)?

标签 javascript flash html canvas easeljs

我有一个淡入然后淡出的 MovieClip。我想在此影片剪辑中找到中途标记并暂停它。但是在 EaselJS 中,我找不到任何方法来获取影片剪辑的当前帧位置。这可能吗?

我想做如下的事情:

 canvas = document.getElementById("introCanvas");
        exportRoot = new lib.MyMovieClip();
        exportRoot.onTick = function () {

            //get the mc's length in frames
            //get the current frame position
            //if current frame postion == mc's lenght / 2
                   //then pause movie clip


        };

谁能为我提供一些建议或想法,帮助我实现上述目标?

谢谢!

最佳答案

阅读文档后,似乎自动分配了一个 TweenJS Timeline 来管理动画中的变化,看起来不像我们在 flash 中看到的任何实际帧。

如果您查看 docs for TweenJS Timeline您可以使用 duration 属性,如文档所述:

Read-only property specifying the total duration of this timeline in milliseconds (or ticks if useTicks is true). This value is usually automatically updated as you modify the timeline. See updateDuration for more information.

因此,如果您获得持续时间并除以 2,或乘以 0.5 ;) 那么您可以找到动画的中间点。尝试在您的 onTick 方法中使用它,看看它是否有效。

关于javascript - 如何在 EaselJS 中获取影片剪辑的当前位置(帧)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10760712/

相关文章:

html - 在元素之前使用 <i> 而不是将元素包装在 <span> 中有什么好处?

javascript - 为什么 Javascript 语法使用多个括号?

actionscript-3 - 闪光灯:crossdomain.xml 被忽略

flash - 声谱As3

apache-flex - 在 AIR 中使用 bytearray 加载 Swf

javascript - 通过javascript在滚动上添加一个css类

html - IE8 不打印 :before pseudo-element 中的图像

javascript - 动态更改输入字段的占位符?

javascript - 客户端 ajaxComplete 调用生成无限 iframe

javascript - 将 css 属性从一个 html 页面转移到另一页面