Question

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???

Was it helpful?

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.

OTHER TIPS

You can have both scenes and a document Class--it's just not well documented on how to do it, unfortunately. Here is some information on what is going on and how to resolve it http://www.developria.com/2010/04/combining-the-timeline-with-oo.html .

Note that you should not be referencing the parent from child movie clips, and using _root was considered bad practice even in the AS2 days (it breaks as soon as you load your movie inside another movie, for instance).

Instead, dispatch events from the child Classes and catch them in the main document and have the main document move the playhead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top