Flash: Actionscript on frame 1 is everywhere! :O
I making a project where I dont have any objects on the scene. I make so the code tells the object 开发者_StackOverflow中文版to spawn. Anyway, when im trying to make a new frame, and make so that if I press a movieclip frame2 should play, the actionscript code from frame 1 follows to frame 2. Why?
If you use actionscript to draw something, frames won't affect it.
Why? When you compile your movie, Flash takes those frames and converts them to actionscript. And the compiler doesn't just handle the drawing but also the cleanup of old objects when they disappear. Since you don't use keyframes to handle your graphics but draw the objects manually by actionscript, you also need to cleanup manually.
To do so you could add a function that you call when you leave the frame, something like:
public function destroy():void{
// clear listeners
someMovie.removeEventListener(MouseEvent.CLICK,onClick);
// delete movies you don't need anymore
someMovieParent.removeChild(someMovie);
}
set second frame to keyframe (press F6) because now it's probably just classic frame
the actionscript in keyframe works also in all following frames until another keyframe appears
精彩评论