Use for...in on jsUnity


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. jsUnity.attachAssertions(window);
  2. var MotionTweens = { suiteName: 'MotionTweens' };
  3.  
  4. var Tweens = Motion.getTweens();
  5. for (var i in Tweens) {
  6. (function () {
  7. MotionTweens['test' + i.replace(/^[a-z]{1}/, function(c){return c.toUpperCase()})] = function() {
  8. var duration = 2000, frames = Math.ceil((duration/1000)*35);
  9. var from = 0, to = 1000, current = 1, result = 0;
  10. while (current++ < frames) {
  11. result = Tweens[i]((current/frames)*duration, from, to - from, duration);
  12. }
  13. assertEqual(1000, result);
  14. }
  15. })();
  16. }
  17.  
  18. jsUnity.log = function (s) {document.write("<div>" + s + "</div>"); }
  19. jsUnity.run(MotionTweens);

URL: http://www.gracecode.com/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.