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

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top