0

I have a flash CS project. I have one stage and some frames. How can I start all project from beginning using AS3? Or start all stage's content from beginning? Is any possibility to do it?

Adam Harte
  • 10,369
  • 7
  • 52
  • 85
canimbenim
  • 659
  • 4
  • 10
  • 23

1 Answers1

1

MovieClip has a function gotoAndPlay(frameNumber). So, you need a movieclip which is added directly to stage and that holds all other movieclips.

Note, that frames counts from 1.

update: That's what I would do: Make a wrapper movieclip, export it for actionscript.

In my main (document) class I would make a variable i.e. world:MovieClip to hold the wrapper. Then I could dynamically create and delete this movieclip, and then create it again.

As I said, if you are being careful with references, the garbage collector will keep the memory clean. Objects that do not have references, eventListeners and that are not in the display list, will be deleted on the next GC iteration.

bassneck
  • 4,053
  • 4
  • 24
  • 32
  • Can I create a stage - empty CS3 project without movie clip? The problem is that I wants to have once again "fresh" movie clip without any rubbish in memory. So I thought that maybe there is a replay() function or something like this that it will start all project since beginning :/ – canimbenim May 04 '11 at 20:25
  • Okkk, I am very close to the solution but how I can get to the parent movieClip from inside? I named it mainGame and in the movie clip in one of the action I try to remove it but I do not have access to mainGame:/ I am not sure that I can do it, if I can not, I have to find way to set a value in the movie clip so probably I need to write my own class and rebuilt all my project :/ Not good :/ But thank you very much for this idea! Next time I will design my application how you wrote. – canimbenim May 04 '11 at 23:53
  • There are several options: after you have added your MC as a mainGame child, the MC would have a parent property, which you can use. Another way is to use static variables but I don't know how you can do that with your architecture. The last option: use events. In your mainGame, do `yourMC.addEventListener("end", yourHandler)` to the MC. In your MC, when you wan't to restart, `dispatchEvent("end")`. Don't forget to remove the listener before you delete the MC – bassneck May 05 '11 at 09:12