Forums → Programming Forum → AS2 Variable Help Needed! - Kind of Urgent!
3 | 3141 |
- 3 Replies
Showing 1-3 of 3
3 | 3141 |
This is in AS2!
Well, yet again, I need help in Flash (big surprise). I'm making an RPG game and for the customization system, I figured it would be best to associate each choice with a variable then use that variable to define how the character looks in the next scene. As an example, I'll use hair color.
Scene 1, Frame 1:
_global.haircolor = 0;
Scene 1, Frame 1, Customizatiomenu_mc, Frame 4:
stop();
bluehairbutton.onRelease = bluehairfunction;
redhairbutton.onRelease = redhairfunction;
function bluehairfunction() {
haircolor = 1;
}
function redhairfunction() {
haircolor = 2;
}
Scene 2, Frame 1:
if (haircolor == 1){
character.head.gotoAndStop(1);
}
if (haircolor == 2){
character.head.gotoAndStop(2);
}
Any ideas anyone?
Also, if there's a better way of doing this character customization thing, please let me know!
Thanks in advance to anyone who can help!
Oops, sorry about the double post!
Could a Mod please delete my other thread of the almost same name?
For simplicity, you might want to use one function, like this:
Scene 1, Frame 1:
_global.haircolor = 0;
Scene 1, Frame 1, Customizatiomenu_mc, Frame 4:
stop();
bluehairbutton.onRelease = hairFunction("blue"
redhairbutton.onRelease = hairFunction("red"
function hairFunction(newColor:String){
switch(newColor){
case "blue": haircolor = 1;
case "red": haircolor = 2;
}
}
Scene 2, Frame 1:
character.head.gotoAndStop(haircolor);
What you're doing here is basically storing the haircolor in the global variable - that's the same. However, with just one function managing the haircolors (function hairFunction) it's easier to view and modify. Also, the whole if functions at the aren't that nessecary, since you store the number of the frame in the global anyway - all you have to do is set the head / hair mc to the right frame!
Hope this helps you, and don't hesitate to ask!
Thanks! I'll try it out when I get a chance, I hope it works lol!
You must be logged in to post a reply!