2011-08-02 49 views
8

对于Google Swiffy(http://swiffy.googlelabs.com/)似乎没有多少支持或讨论。是否有可能从JS中暂停/恢复/操作swiffyobject?

是否有可能从JS有效地暂停/恢复/操作swiffyobject?

使用标准的Google输出,我注意到swiffyobject可以在控制台中找到几个属性;特别是frameRate。例如,这个属性可以被操纵吗?

回答

1

通过unminified的runtime.js - 有可能实现我想要的行为。

线3312(unminified - 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. 
5

对不起,我是法国人;) 我一直在找解决方案能够正确处理Swiffy动画。 由于新版本(5.0)的谷歌代码已经改变,我不能再在网上发现小黑客maniupler动画... 对于弊,我编码的力量找到一个解决方案..这对我来说很简单,干净..(不接触源Swiffy不在!) 其实这篇文章的任何部分:swiffy/javascript

能Flash变量Swiffy与恢复(在AS2和AS3它应该工作太..)

侧面JavaScript可以做这样的事情:

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

和th在功能enterFrame事件闪光电子身边...:

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

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

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

,这就是它! 要你组织你想要的方法,但..它的工作原理;)如果你想以后重新使用它 必须重新参加未定义的变量;)

+0

在此添加swiff标签以获得更多相关流量。 – WEFX

6

有关最新发布Swiffy与(Swiffy与运行5.2版https://www.gstatic.com/swiffy/v5.2/runtime.js)我这样做。

1.使用jsbeautifier.org,如samb的帖子中所述。

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

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

3.Duplicate此功能以不同的名称,并替换的start()停止()

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

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

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

5.Duplicate此功能,并调用它一样的,你用停止()中创建新的功能,并与停止更换开始。在我的情况下,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(); 
});