So I recently had to move a lot of code from the timeline to a document class, mainly to be able to code in my favourite code editor. Anyway I thought I would share a little trick I used to handle the multiple frames code was scattered on.
All this snippet does is add the frame scripts for every frame in a swf no matter how many frames there is.
I use generic function names ‘frame1′, ‘frame2′ and so on depending on the frame number.
Code:
public function addFrameScripts():void { var i:uint = 0; var numFrames:int = totalFrames; for ( i; i < numFrames; i++ ) { addFrameScript( i, this[ 'frame' + ( i + 1 ).toString()]); } }
Another thing to note is if you are using variables and functions across the timeline you will need to make them public to make sure they can be accessed on any frame. I tripped up on this and thought it would be useful to know
.
