I would like to know how to create in Adobe Flash CS3 a button that will execute a function (like gotoAndPlay(51) but ONLY when playhead hit a defined keyframe from timeline. Here is a drawing that does explain better what I want to do
So after I click the button, it will wait until the playhead hit the closest defined keyframe, only then it will execute my desired function.
Any help is appreciated.
There are a few ways to accomplish this. The most succinct way is to use an undocumented* feature called
addFrameScript
What you can do with that method, is place code on a specific frame at runtime.
So, you could do something like:
*-one should point out that using undocumented features of a language comes with risk of the feature being taken out on a future version, however given the current life cycle stage of AS3, this is very unlikely