Hmmm.... Let me see if I understand you correctly:
I'm assuming that pagenumber is a variable on your root timeline, and that you're putting this line:
gotoAndPlay(MovieClip(root).pagenumber);
into a function the timeline of your movieclip, that you're calling somehow.
Sorry if that's not right...
If it is, it could be that the function inside the movieclip is being called before pagenumber is being set - or that it's not being called at all. Did you want the MC to jump to "pagenumber" when the function you posted is run? If so, that's much easier:
function onClick2(evt:MouseEvent):void{
var pagenumber = "pg03";
//add this line
mc.gotoAndPlay(pagenumber);
switch01.gotoAndStop("red");
gotoAndPlay (2);
}
I hope that works. If not, let me know if I'm assuming the right things.
Last edited by LunaJester; 06-02-2009 at 03:20 PM.
The thing that seems to be tripping the code up is the declaration of pagenumber. In as3, if you declare a variable within a function, it only "counts" as a variable for that function (then is erased once it's done).
It's an easy fix though, just declare it as a global variable by putting this:
var pagenumber:String = new String();
at the very beginning of your code, then erase "var" from the uses of pagenumber in your functions (else, you'll be declaring it twice, which as3 doesn't allow). That should fix it. (And, sorry, I should have noticed that when I looked at the code above.)
Also, I uploaded a version with changes made, in case that was less clear than I thought.
Last edited by LunaJester; 06-03-2009 at 12:49 PM.