flash actionscript:
I have read a few times that it is best practice to put all your actionscript
in the first frame of the main timeline. Now that I have Flash 8 and 'learning
actionscript 2', I'd like to get to grips with actionscript properly, and this
is one area that I'm having problems with.
1. this appears to contradict the rule that actionscript will only work on
objects that exist in the same frame that the actionscript is in. e.g., in the
following simple movie I have a movieclip in frame one of a swf movie. The mc
contains a simple tween, a play button and a return button. Hit the play button
and the tween plays. When it reaches the end the mc stops. Hit the return
button and the mc returns to frame 1 and stops.
The script is in frame 1 of the main timeline.
I can only get it to work if the play and return buttons exist throughout the
entire movie. If the play button only exists in frame 1, and the return button
only exists in the last frame of the mc, then it doesn't work. To make it work
I have to put the action script for each button in the same frame of the actual
mc that each button exists in.
I assume I'm missing something simple, but with bigger, more complex movies I
have spent hours trying to get things to work by writing script in frame 1 of
the maintimeline, only to give up and put the script in the same frame as the
object i am targeting.
movieClip_mc.stop();
movieClip_mc.playButton_btn.onRelease = function(){
movieClip_mc.play();
};
movieClip_mc.returnButton_btn.onRelease = function() {
movieClip_mc.gotoAndStop(1);
};
2. If you import swiffs into a main movie, should the script for the imported
movie be in frame 1 of the main movie, or is it acceptable to keep it within
the imported movie?
So, should I be aiming to write every single scrap of action script in frame1
of the main timeline and if so how do I get around the problem in 1. above?
Thanks a lot for any help on this one.