Is it possible to pause / resume / manipulate swiffyobject from JS?

Google Swiffy (http://swiffy.googlelabs.com/) seems to have little support or discussion.

Is it possible to effectively pause / resume / manipulate swiffyobject from JS?

Using standard Google output, I noticed that swiffyobject can be found in the console with several properties; especially frameRate. Could this property be manipulated, for example?

+8
javascript html5 flash google-swiffy
source share
3 answers

Without decreasing runtime.js, we managed to achieve the desired behavior.

On line 3312 (unminified - jsbeautifier.org)

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

And on line 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 } }; 

Then, using the console, you can pause / resume the animation using:

 stage.start(true) // PAUSE the animation. stage.start() // RESUME the animation. 
+1
source share

For the latest version of Swiffy (Swiffy runtime version 5.2 https://www.gstatic.com/swiffy/v5.2/runtime.js ) I did this.

1. Use jsbeautifier.org as indicated in the samb post.

2. Find the function containing .start (). In my case...

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

3.Disable this function with a different name and replace start () with stop ()

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

4. Record the declaration of the function containing .start (). In my case, db.

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

5. Duplicate this function and name it the same as the new function that you created using the stop () function, and replace start with stop. In my case, myNewFunction.

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

What is it.

Now you can call my anim.stop ();

eg.

 //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(); }); 
+6
source share

Sorry for my English, I'm French;) I was looking for a solution to handle Swiffy animations correctly. Since the new version (5.0) has changed the google code, and I can no longer animate the maniupler with small hacks found on the network ... For the minuses, I coded the force to find a solution .. which seems very simple and clean to me .. (without touching source Swiffy!) Virtually any part of this post: swiffy / javascript

Can be restored using flashvars Swiffy (in as2 and as3 it should work too ..)

side javascript can do things like this:

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

and the flash side in enterFrame ... function:

 _root.onEnterFrame = function(){ switch(_level0.myresponse){ case 'play': _root.play(); break; case 'pause': _root.stop(); break; default : break; } _level0.myresponse = undefined; } 

what is it! The methods you want are organized for you, but .. it works;) You need to reset the undefined variable if you want to reuse it later;)

+5
source share

All Articles