TeamPhotoshop
Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
Forum Home Latest Posts Search Help Subscribe

Syntax Adjustments

Page: 1 Reply
Dec 20th 2003#134285 Report
Member since: Dec 24th 2001
Posts: 222
Ive pretty much been doing sloppy programming in flash for the duration of my use. Ive decided to try and get it right with modularizatoin and what not. Im working on a little game to give to my little sister as a christmas present now and i was wondering is there a special way i should declare constants? or should i just declare them as normal variables? and also when im giving a variable a value is it important that i start it off like:

var whatever = whatever;

or is ok to just say

whatever = whatever;

without initializing it as a variable.....i didn't think there was any difference between the two but i was reading something the other day and it appeard to me that the two served completely seperate tasks....as though the second example above was declaring an object or an object class or something crazy like that.......so yeah basically looking for some advice on syntax and declaring what i will us as constants
Reply with Quote Reply
Dec 21st 2003#134462 Report
Member since: Apr 25th 2003
Posts: 1977
im guessing your using flash 5 or later.

a special way i should declare constants? or should i just declare them as normal variables?

yup. Just normal variables.


var whatever = whatever;

or is ok to just say

whatever = whatever;


"var" is not needed. Those statements basically say the same thing.....there is no need to initialize the variable as in other scripting languages.

Also have you tried dot syntax?? So instead of

tell Target (this_mc){
gotoAndPlay(2);
}

you would write

this_mc.gotoAndPlay(2);


The second way (dot syntax; using dots between the affected symbol and its properties/methods) is easier and will clean up your code. Also it leaves less chance or forgetting to close a set of brackets (as in a 'tell target' or similar).

Im working on a little game to give to my little sister as a christmas present

Thats a cool idea. Glad to see flash being used for a diff. purpose for once.
Reply with Quote Reply
Dec 22nd 2003#134502 Report
Member since: Dec 24th 2001
Posts: 222
thanks man i appreciate it
Reply with Quote Reply
Page: 1 Back to top
Please login or register above to post in this forum