gree / lwf

LWF - Lightweight SWF
http://gree.github.com/lwf/
zlib License
627 stars 167 forks source link

Updating the flash with a delta time of 0 still calls OnEnterFrame #145

Open DelSystem32 opened 9 years ago

DelSystem32 commented 9 years ago

I have this code:

lwf.AddMovieEventHandler(lwf.rootMovie.instanceId, enterFrame:MyHandler);

void MyHandler(LWF.Movie m) {
    Debug.Log("hello");
}

If I call:

lwf.Exec (0);
lwf.Exec (0);

Or:

lwf.UpdateLWF(0);
lwf.UpdateLWF(0);

I still get "hello" printed out several times, even though there has been 0 milliseconds since the last time the method was called, which is not enough time to enter another frame. This can't be intended behavior, right?

Actually, if I run this code...

int id = lwf.AddMovieEventHandler(lwf.rootMovie.instanceId, enterFrame:MyHandler);
UpdateLWF(0);
lwf.RemoveMovieEventHandler(lwf.rootMovie.instanceId, id);

...then "hello" is printed out three times, just from that single UpdateLWF()! Even though it is only called once between adding and removing the handler and the tick is zero time.

Edit: Seems like Exec() wants -1 where UpdateLWF() wants 0. UpdateLWF calls Exec and if UpdateLWF received 0 as tick it will change tick to -1 for Exec. Kinda confusing, especially since the suggested value for the optional parameter "tick" in Exec is set to 0.