The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.34 / 5.00 31,296 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.07 / 5.00 10,082 ViewsI've been having a bit of troubles figuring out this little problem...
I've got a variable called 'score' on the main timeline, and then I have some actions on a frame of a movieclip's timeline...
on that frame, I want to have a line saying 'score++;'... but, of course, I can't just access the variable from there like that... I tried googling this to find some answers, but nothing I can find seems to work for this.
I feel like this is a stupid thing to be having problems with, so sorry if I sound like an idiot.
Any and all help is greatly appreciated!
There is no _global variables like there was in AS1-AS2. Now you have to acess these variables through a static class. It is pretty simple, create an Actionscript file and name it GlobalVariables for example and create a static function or static variables for your score, then just call it through the class.
Example:
GlobalVariables.score++;
GlobalVariables.addScore();
etc
Do not create a global class.
Instead, dispatch an Event, listen for it where "score" is defined and modify it accordingly.
I use MovieClip(root). to get access to variables declared on the main timeline e.g.
MovieClip(root).score ++;
MovieClip(root).highscore = MovieClip(root).score;
This is apparently very bad practice and a little long-winded but I have made several games now and used this throughout without problems, Although I'm using AS3 I still like to do some things AS2 style ;-)