Saturday, September 01, 2007

Keyframes, MovieClips and Listeners

In Flash CS3... Say you have a MovieClip instance named "my_mc" on frame 1 and add an event listener and you then create a keyframe in frame 2.

If you move that keyframe in frame 2 to another layer, it no longer has the listener. This action creates a new instance of that symbol

If you move the keyframe in frame 2 to frame 3 and insert a blank keyframe between the two, it no longer has the listener because this action also results in a new symbol instance on frame 3.

If you swap a different symbol, it no longer has the listener (not a surprise).

BUT... If you keep the keyframe in the same layer and don't swap the symbol, the instance still has the event listener. Keyframing on the same layer without breaks retains the same symbol instance.

I suppose not that surprising once I think about it, that by moving the symbol instance to a new layer the result is a different instance of the same symbol. A quick trip through the debugger confirmed this.