Search code examples
flashactionscript-3airmovieclipscene

After loading Scene 1, all movie clips are null! Why?


OK

In Scene 1, after pressing a button user goes to Scene 2. After coming back from that to Scene 1, All movie clips in other layers are null.

This is my code that goes to Scene 1:

MovieClip(this.root).gotoAndStop(1, "Scene 1");

WHY???


Solution

  • If you have references to a timeline instance in your code and change scene they will lose the references. The instances of the scene will also be removed when you leave the scene, and recreated when you enter again.

    I recommend you to not use scenes at all and look into using a document class for your flash file. Maybe you already have that.

    If you still want to use scenes, put a init function in the first frame of each scene. That will make it easy for you to setup the scene references.