Reputation: 25
I haven't worked in AS3 in almost a year because I had moved on to working with Unity, but I decided to come back and work on some more stuff because I really liked it. This question is really simple, I just need a refresh:
I'm on the main timeline of Flash and I want to trace the current frame of the timeline within "player". For some reason it just shows up as 1.
trace(player.currentFrame);
After working with this I found out that it was caused by the function not being updated constantly. How do I fix this? How can I make a function that updates itself?
Upvotes: 0
Views: 42
Reputation: 5255
The object will dispatch an Event
of type Event.ENTER_FRAME
when the duration of a single frame went by. (this means the event is still periodically dispatched even though the timeline is not advancing)
This would allow you to periodically check the currentFrame
property.
However, depending on what you want to achieve, there are other options to consider.
If for example you want to trigger a certain action upon reaching a certain frame, just put a label at that frame and listen for a FrameLabelEvent
. This improves readability, given that you use descriptive label names.
It also helps maintainability, as you can freely move the label, (if you add a few frames to an animation, for example) without breaking the code.
Upvotes: 1