8

关于 Google Swiffy (http://swiffy.googlelabs.com/) 的支持或讨论似乎很少。

是否可以有效地暂停/恢复/操作来自 JS 的 swiffyobject?

使用标准的 Google 输出,我注意到可以在控制台中找到带有一些属性的 swiffyobject;尤其是帧率。例如,可以操纵此属性吗?

4

3 回答 3

6

对于最新的 Swiffy 版本(Swiffy 运行时版本 5.2 https://www.gstatic.com/swiffy/v5.2/runtime.js),我这样做了。

1.使用 samb 帖子中提到的 jsbeautifier.org。

2.找到包含 .start ()的函数。在我的情况下...

db(N, function () {
    var a = this.Dg;
    this.ck(function () {
        a.start()
    })
});
db(Yj[I], Yj[I].start);

3.用不同的名字复制这个函数,并将start()替换为stop()

myNewFunction(N, function () {
    var a = this.Dg;
    this.ck(function () {
        a.stop()
    })
});
myNewFunction(Yj[I], Yj[I].stop);

4.找到包含.start()的函数的声明。在我的情况下db

function db(a, b) {
    return a.start = b
}

5.复制此函数并将其调用与使用stop()创建的新函数相同,并将start替换为stop。在我的情况下myNewFunction

function myNewFunction(a, b) {
    return a.stop = b
}

就是这样。

现在你可以调用我的anim.stop();

例如

//create anim
var anim = {swiffy code};
var myAnim = new swiffy.Stage(document.getElementById('animContainer'), anim);
myAnim.start();

//some button click
myButton.on('click',function(){
  myAnim.stop();
});
于 2013-06-13T09:55:54.747 回答
5

对不起我的英语我是法国人;)我正在寻找一种能够正确处理动画 Swiffy 的解决方案。由于新版本(5.0)谷歌代码发生了变化,我不能再用网上找到的小技巧来操纵动画......对于缺点,我编写了代码来寻找解决方案..这在我看来非常简单和干净.. (没有触及源 Swiffy!)事实上这篇文章的任何部分:swiffy / javascript

可以用 flashvars Swiffy 恢复(在 as2 和 as3 中它也应该可以工作..)

侧 javascript 可以做这种事情:

function playMovie(){
    stage.setFlashVars('myresponse=play');
    return false;
  }
  function stopMovie(){
    stage.setFlashVars('myresponse=pause');
    return false;
  }

和函数 enterFrame ... 中的闪光灯一侧:

_root.onEnterFrame = function(){
switch(_level0.myresponse){
    case 'play':
        _root.play();
        break;

    case 'pause':
        _root.stop();
        break;

    default :
        break;
}
_level0.myresponse = undefined;
 }

就是这样!给你组织你想要的方法,但是..它有效;)如果你想稍后重用它,必须重新获取未定义的变量;)

于 2012-12-21T21:07:53.860 回答
1

未缩小 runtime.js - 可以实现我想要的行为。

在线 3312(未缩小 - jsbeautifier.org)

M.start = function (arg) {
this.T[Qa]();
if(arg){
this.cb.start(arg)
}else{
this.cb.start()
}
};

在第 3823 行:

M.start = function(arg)  {

    if(arg){
        console.log(arg);
        window.clearInterval(window.pauseAnimation)

    }else{
        window.pauseAnimation = window.setInterval(Ob(this.ne, this), 40 );
        if (!this.ie) this.ie = !0, this.ne(), window.pauseAnimation

    }     

};

然后使用控制台,可以使用以下命令暂停/恢复动画:

stage.start(true) // PAUSE the animation.
stage.start() // RESUME the animation.
于 2011-08-02T21:33:43.850 回答