need help

Subscribe to need help 19 posts

avatar for phore_eyes phore_eyes 427 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

 
avatar for arcaneCoder arcaneCoder 2354 posts
Flag Post

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

 
avatar for phore_eyes phore_eyes 427 posts
Flag Post

ok thanks

 
avatar for JudeMaverick JudeMaverick 8844 posts
Flag Post

That remainder thing… Why did they do that?

Without the %, is there any error?

 
avatar for WMDs WMDs 8 posts
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 !!!!)

 
avatar for JudeMaverick JudeMaverick 8844 posts
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.

 
avatar for phore_eyes phore_eyes 427 posts
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

 
avatar for arcaneCoder arcaneCoder 2354 posts
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.

 
avatar for JudeMaverick JudeMaverick 8844 posts
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.

 
avatar for Mitijea Mitijea 70 posts
Flag Post

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

 
avatar for phore_eyes phore_eyes 427 posts
Flag Post

would it be the same for dividing???

 
avatar for arcaneCoder arcaneCoder 2354 posts
Flag Post

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


No its not.

 
avatar for Mitijea Mitijea 70 posts
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.)

 
avatar for phore_eyes phore_eyes 427 posts
Flag Post

kk thanks mitijea

 
avatar for Mitijea Mitijea 70 posts
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
}

 
avatar for JudeMaverick JudeMaverick 8844 posts
Flag Post

No its not.

Really? Lollerz, I was wrong then :P

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

 
avatar for pel6413 pel6413 74 posts
Flag Post

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

 
avatar for 2DArray 2DArray 112 posts
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.

 
avatar for Janck Janck 253 posts
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.