need help

19 posts

Flag Post

i’m making a game that (obviously) has lot’s of cvariable this is the code in my first frame

var coins = 0

var lives = 0

var score = 0

var easyscore = 0

var normalscore = 0

var hardscore = 0

var absolutlytotalycrazyscore = 0

var easycomplete% = 0

var normalcomplete% = 0

var hardcomplete% = 0

var absolutlytotalycrazycomplete% = 0

var easytime = 0

var normaltime = 0

var hardtime = 0

var absolutlytotalycrazytime = 0

this is the error message

Scene=Scene 1, Layer=actions, Frame=1: Line 8: ‘;’ expected

var easycomplete% = 0

any help here

 
Flag Post

Dont use the % sign in variable names, thats reserved as an operator.

 
Flag Post

ok thanks

 
Flag Post

That remainder thing… Why did they do that?

Without the %, is there any error?

 
Flag Post

Use strong syntax helps with debugging as well reduces load.

var coin:Number = 0;

EDIT: Oh yeah Flash dosnt use _root and globel anymore it has private and public scope
(dammm you !!!!)

 
Flag Post

Why are they local variables? You must have learnt it from evil jmtb02’s Flashwiki.net

There is no need to use var as long it’s in the frame.

 
Flag Post

thanks
also lets say i wanted to make variable score = variable time x variable score
what would the code be??
and would it work wth addition and subtraction??
thanks

 
Flag Post

EDIT: Oh yeah Flash dosnt use _root and globel anymore it has private and public scope (dammm you !!!!)


AS2 still has that. AS3 is the one that has changed a bit. Additionally, public and private namespaces are a bit different than the “scope” you are referring to.

There is no need to use var as long it’s in the frame.


It should still be used in order to train proper practices.

 
Flag Post

It should still be used in order to train proper practices.

There’s no need to practice. :P It’s only used in functions.

thanks also lets say i wanted to make variable score = variable time x variable score what would the code be?? and would it work wth addition and subtraction?? thanks

score=time*score

Doesn’t sound right. Get another variable so you don’t have some random bug.

 
Flag Post

If both scores are the same variable, you could just write it as :
score *= time;

 
Flag Post

would it be the same for dividing???

 
Flag Post

There’s no need to practice. :P It’s only used in functions.


No its not.

 
Flag Post

Yes, Phore_Eyes, you can do the same with dividing. Also addition and subtraction.
Say you want to divide a number VarA in half, you’d use VarA /= 2;
If you want to add three, write VarA += 3;
Or subtract VarB, VarA -= VarB;

Note: if you just want to add 1 or subtract 1 you can use, VarA++; or VarA—; respectively.

Edit: And to clarify why you originally had an error was because you used the % symbol which is the modulo operator. You can use the % the same way as the other operators:
VarA %= 7;
VarA will contain the remainder of the original VarA after dividing it by 7. Ex) If VarA was 15, it would now be 1 (15 % 7 = 1 since 7 goes into 15 two times with a remainder of 1. It just keeps the remainder.)

 
Flag Post

kk thanks mitijea

 
Flag Post

That remainder thing… Why did they do that?

Not sure if this is what you are asking, Jude Maverick, but if you are wondering what use % could be, a practical example might be:

Say you want something to happen once every fifteen frames, then you can easily do this with % by writing inside an onEnterFrame function:

FramesSinceStart++;
if (!(FramesSinceStart % 15)) {
// Something Happens
}

 
Flag Post

No its not.

Really? Lollerz, I was wrong then :P

I know the function for %. It gives you the remainder.

 
Flag Post

% is the modulo operator, as jude said it returns the remainder.
so 20%7==6

 
Flag Post

Haha, using var when it’s not necessary is really just extra filesize in my opinion. Granted, it’s obviously not going to make any legitimate difference, but there’s really no need to “practice best practices” in cases when they don’t apply. Just another one of those old school opinions of mine.

 
Flag Post

Granted, it’s obviously not going to make any legitimate difference, but there’s really no need to “practice best practices” in cases when they don’t apply. Just another one of those old school opinions of mine.

‘Greater interpretation and compiling speed’ + ‘preparing you for other languages like C that are bitchy about that sort of thing’ are always good.