I’m not a developer and over the course of the past year during which I’ve learned a lot of AS3, I have probably not come close to applying what would be considered “best practices.” I have lots of code that could probably be dramatically changed to improve performance.
Here’s a bit of my code that I’d like advice about. Is there a different technique I can use to do the following, that’s more streamlined?
masterCounter is variable that’s iterated every tenth of a second on the root timeline. The following code is in a movie clip that’s been added to the stage:
addEventListener(Event.ENTER_FRAME, s003Listener);
function s003Listener(event:Event):void {
if (!event.target.parent.masterIsPlaying) {
pauseAudio();
}
if (event.target.parent.masterIsPlaying) {
resumeAudio();
}
if (event.target.parent.masterCounter == 1) {
startAudioBkgd();
}
if (event.target.parent.masterCounter == 10) {
startAudio01();
}
if (event.target.parent.masterCounter == 50) {
Tweener.addTween(s003Presented, {alpha:1, time:fade});
}
if (event.target.parent.masterCounter == 62) {
playWhoosh();
}
if (event.target.parent.masterCounter == 65) {
s003Presented.gotoAndPlay(2);
}
if (event.target.parent.masterCounter == 95) {
Tweener.addTween(s003Presented, {alpha:0, time:fade});
Tweener.addTween(s003title, {alpha:0, time:fade});
}
// ...etc. Imagine there are a hundred of these if statements...
Don’t flame me for being a Flash Butcher!
Thanks for any help!