I’ve looked through similar question on this site and can’t find a solution, so here is my problem:
I have a save function that saves some data.This function is in 1 movie clip in another movie clip. After the save I want to gotoAndStop(1) of the main time line not the current nested one…can anybody help?
Below is the code:
function save()
{
var oldname:String = so.data.username;
so.data.username = oldname + tf.text + " " + nf.text + "\n";
tf.text = "";
nf.text = ""; // resets textfields
so.flush(); // writes changes to disk
trace("Saved");
gotoAndStop(1); <<----this must goto frame 1 of the main time line??
}
This is AS3. In AS2 I used to be able to call _root. or _parent. and that would work fine but now it throws a compiler error. Stage.gotoAndStop(1); also doesnt work…
Appreciate any help,
Thanks in advance
Luben
You can access the topmost
DisplayObjectusingroot. BecauseDisplayObjectdoes not have agotoAndStop()method, attemptingroot.gotoAndStop()will result in:You can however typecast
roottoMovieClip1, which will grant access to it:Typecasting to
MovieClipwill also allow you to access user-defined properties and functions on the main timeline – this is because MovieClips aredynamicwhich drops compile-time constraints on what properties and methods you are allowed to access on an object.1Except for in cases where you have a document class that inherits
Spriteinstead ofMovieClip.