I've got a FLA document for an animation I'm creating and I'm wondering how I use an external AS file when the animation has multiple scenes/timelines.
Do I just put every function I reference in the AS file and then call the functions from within the animation timeline when I need them? Is there a better way to do this?
Thanks
Yes, you can attach the same .as3 file to multiple movieClips using Export for actionScript then use
parent.yourfunctionName();
To access various functions, as long as those functions are public:
public function doSomething ():void { trace ("function was called from timeline") }
if you need to move further up, do parent.parent.parent etc, or root.instanceName.instanceName etc
Alternately (and better), you can put all your public functions in a document class using file->settings->script->document class, and then use something like parent.parent or root to reach your functions, or you can have the document class pass a reference to itself to all movie clips that require communication:
as3 calling a function in Main.as Document Class from another class
Placing scripts on the timeline is done less often since As2, but it's still the easiest way to have something happen at a certain point in the timeline, and it still works. If you want to do it a harder way you can listen for certain frames or labels from within an enterFrame handler on your movieClip code.