gree / lwf

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

Getting LWF.Bounds of a LWF.Movie immediately #144

Open DelSystem32 opened 9 years ago

DelSystem32 commented 9 years ago

Right now it seems like the only way to get the bounds of a LWF.Movie is to do this:

private LWF.Bounds theBounds;
private void BoundsFetcher(LWF.Movie m) {
    theBounds = m.GetBounds();
}
public LWF.Bounds GetBounds (string mcInstanceName = null) {
    lwf.SearchMovieInstance ("instancename").RequestCalculateBounds(BoundsFetcher);
    lwf.Exec (-1);
    return theBounds;
}

However this means you have to update the flash once. Is there a better way to do it, without using RequestCalculateBounds()?

Or using RequestCalculateBounds() but not having to call Exec(-1)?

Edit: Changed the incorrect 0 to the correct -1.

DelSystem32 commented 9 years ago

A workaround would be to avoid calling Exec() and simply have LWF RequestCalculateBounds() after every single update that it does, on all its LWF.Movies. However then I ask how can I loop through all LWF.Movies in a LWFObject? I know about lwf.buttonHead to loop through all buttons however there isn't anything similar for movies or is there?

Edit: That workaround is no good since if a script repositions a MovieClip within the flash and then tries to get the bounds then the bounds will not have been updated to the changes. Seems like I need to call Exec(), meaning I will need to workaround the problem with any false enterFrame MovieEvents that might come out of the extra Exec() call. Note to anyone reading this: -1 should be given to Exec(), not 0.

Leaving question open since it would still be good to know if there is a way to get the bounds of a MovieClip without having to call Exec()?