aduros / flambe

Rapidly cook up games for HTML5, Flash, Android, and iOS.
https://github.com/aduros/flambe/wiki
MIT License
745 stars 118 forks source link

current frame number of a movieclip #331

Open ramachandran-prazas opened 9 years ago

ramachandran-prazas commented 9 years ago

Hi,

Could you please let me know how I can access the current frame number being played. Its stored at MovieSprite._frame but since its private I can't access it. Is there any other way to do this? Its a flump exported movieclip.

Thanks for your help.

markknol commented 9 years ago

This is a hacky solution but you can add metadata to the function who wants to access the frame number; then you can access private variables. You can create a util class with this function:

@:access(flambe.swf)
public static function getMovieSpriteFrame(movieSprite:MovieSprite) return movieSprite._frame;

See http://haxe.org/manual/lf-access-control.html

I also wonder why frame isn't exposed, @aduros ?

aduros commented 9 years ago

No reason, exposing frame would be fine with me.

It's not quite as simple as making _frame public though. _frame is currently only updated in onUpdate, and needs to be synced with position.

ramachandran-prazas commented 9 years ago

Thanks a lot for the reply. Will try out your suggestions

On Wed, Mar 11, 2015 at 7:11 PM, Bruno Garcia notifications@github.com wrote:

No reason, exposing frame would be fine with me.

It's not quite as simple as making _frame public though. _frame is currently only updated in onUpdate, and needs to be synced with position.

— Reply to this email directly or view it on GitHub https://github.com/aduros/flambe/issues/331#issuecomment-78264462.