PDA

View Full Version : Trouble Understanding Placement


PhillyPride88
06-08-2010, 04:56 PM
Hi there everyone! After being on the sidelines and playing a few flash games, I have had the urge to learn Flash (and subsequently actionscript), and create a game of my own.

Things seem simple and tricky at the same time. I picked up buttons and how to use those to move to a different frame, but the game I want to make needs to use variables as path deciders.

Alright, say I have set up a variable called money. I set it up as {money = 1000;} making it a constant throughout my frames.

I made a frame right after that that is identical to the other. I then made a button on the first frame that would go to the next frame.

What I tried after that failed miserably. Pretty much, I coded the second frame with the command...

if (money == 1000){
_root.gotoAndStop(b);
}

By the way, I had set up three other frames as go to frames (a, b, and c)

I also set up two other commands

if (money < 1000){
_root.gotoAndStop(a);
}

and

if (money > 1000){
_root.gotoAndStop(c);
}

I was expecting when I tested the flash that after I clicked the button to get to the frame that would make the decision...nothing changed, it just stayed there. What am I doing wrong?

I have more questions, but I figured I'd take it one at a time.

adninjastrator
06-08-2010, 10:49 PM
If a, b, and c are frame labels, they will need to be inside quotes.
_root.gotoAndStop("b");
When going to a frame number, quotes not needed.
Best wishes,
Adninjastrator

PhillyPride88
06-08-2010, 11:06 PM
Thank you very much, someone over at another site just helped me too.

I can happily said that I got my code work now (to the point where I yipped in excitement).

Here is my next question if you or anyone else is up to helping me ...

So now I know how to make my game understand variables. However, I have to figure out how to make variables not stay constant.

I'm going to try to avoid making another topic by asking it here.

In my coding, I have {money = 1000;}

I can make commands that will add and deduct from that 1000 on a certain frame, however, when I switch to the next frame, it will just reset to 1000.

What would be a good equation to following a dynamic variable?