Search code examples
flashactionscript-3cs4instanceskeyframe

Is there documentation on how flash manages named instances across key frames?


I'm looking for technical documentation on how Flash manages object instances with the same name across key frames.

So far, I've noticed that when the play head moves to another frame, if an object with the same name has the same type, then the instance is preserved along with its dynamically set properties.

On the other hand, as soon as the play head goes to a frame where the named instance is a different type, then it creates a new instance of the new type (with the original name), and the original instance of the old type is permanently discarded and all dynamically set properties on the named instance are lost (because it's a new instance).

If you go back to the original frame, it does not restore the original instance, but treats it as yet another change, and constructs a new instance again. Is there any documentation that describes this behavior?

Similar question on "continuity of timeline instances": http://www.kirupa.com/forum/showthread.php?t=316612 I too was surprised that properties carry over. It seems like a run-time feature, where Flash will create a new instance, only if the (instance name / symbol type) pair changes in the next key frame (i.e. if named instance "obj" refers to a "ball" in both keyframes, then it will remain the same instance; but if "obj" refers to a "square" in the next keyframe, then a new instance of "square" will be created). It makes sense, but is this behavior guaranteed?


Solution

  • I have never seen this officially documented since I started with AS in Flash 5.

    Your observations match mine, but another case is "same name, same type, new keyframe, different layer" which reinitializes the object in AVM1. I am not sure what AVM2 does, since I really try to avoid these situations, but this can be a decent way to get a MC to reinit on the timeline if you need to.