motion.Actuate and requestAnimationFrame()

54 views
Skip to first unread message

Atul Kumar

unread,
Oct 1, 2015, 7:30:47 AM10/1/15
to Haxe
Hello,

I am using Actuate for targeting js. I recognized animations are running a bit 'choppy' and investigated a little bit. In SimpleActuator.hx I found this:

#if !actuate_manual_update
#if (flash || nme || openfl)
Lib.current.stage.addEventListener (Event.ENTER_FRAME, stage_onEnterFrame);
#elseif lime
Application.current.onUpdate.add (stage_onEnterFrame);
#else
timer = new Timer (Std.int(1000 / 30));
timer.run = stage_onEnterFrame;
#end
#end

So it seems that stage_onEnterFrame() is called with 30fps. Instead I would rather use requestAnimationFrame() instead.

I guess I can somehow set "actuate_manual_update" somehow and call stage_onEnterFrame myself somehow. But how would I do that? Is "actuate_manual_update" some kind of compiler argument?

Or is there any other way to make Actuate use requestAnimationFrame() instead of its own timer?


Thanks in advanced.

Joshua Granick

unread,
Oct 1, 2015, 10:54:17 AM10/1/15
to haxe...@googlegroups.com
Should be able to do #elseif js here with requestAnimationFrame code. Feel
free to contact me if that doesn't work out :)
--
Using Opera's mail client: http://www.opera.com/mail/

Atul Kumar

unread,
Oct 1, 2015, 11:10:45 AM10/1/15
to Haxe
Thanks Joshua. I will probably fork it and give it a shot.

I would prefer some way though without changing code inside Actuate itself, so I do not lock myself out of updates.

It seems to me your design provided a way to call stage_onEnterFrame() from outside by using these conditionals. Maybe it would better to leverage that? Since stage_onEnterFrame() is static I just could throw it inside my loop() function. But for that I would have to set "actuate_manual_update" to true somehow. How do I do that?

Cheers

Atul Kumar

unread,
Oct 1, 2015, 11:20:08 AM10/1/15
to Haxe
Actually never mind.. I just found out.

For anybody else interested: just use compiler flag "-D actuate_manual_update". Then just call "motion.actuators.SimpleActuator.stage_onEnterFrame()" in your requestAnimationFrame handler and Voila.. Actuate runs in glorious 60fps :)

Thanks

Joshua Granick

unread,
Oct 1, 2015, 11:23:16 AM10/1/15
to haxe...@googlegroups.com
Try and make the change within Actuate, then do a pull request. I'll
update the library, and you won't have to "manual update" again :)
Reply all
Reply to author
Forward
0 new messages