Forum Topic: AS: Sweet Debugging syntax

(1,847 views • 1 reply)

This topic is 1 page long.

<< < > >>
None

Inglor

Reply To Post Reply & Quote

Posted at: 6/28/05 02:18 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

AS: Main

This thread is about the correct syntax, it mostly applies to mx 2004

Remmember people, correct syntax does several things:

1)Make your code more readable
2)Makes errors easier to find for the debugger

Variables

Partial decleration:
Whenever you use a variable, declare it first, you declare a variable with the "var" command
for example:

var i;

declares a variable named I

var arr=new Array();
declares a new variable names it arr and creates a new array for it to point at

Full decleration:

Whenever you make full decleration (which is importent for the compiler to identify your errors) you also specify the return type, for example

var i:Number;

declares a number variable called i

var arr:Array=new Array();

declares a new array.

var s:String="lololololol";

creates a new string variable, names it s, and puts 'lolololol' in it

Functions

Always specify the return type, if there isn't any, the function returns "Void";

for example

function lolk():Void{
trace("lolk");
}

another example

function lolno():Number{
return 1337;
}

this way the compiler warns you if you have the wrong return type, it helps alot with errors.

remmember, params also have types, for example

function sum(num1:Number,num2:Number):Number{
return num1+num2;
}


None

SymbolLock

Reply To Post Reply & Quote

Posted at: 7/20/05 04:33 PM

SymbolLock EVIL LEVEL 02

Sign-Up: 05/08/04

Posts: 98

Yeah!!!!


All times are Eastern Standard Time (GMT -5) | Current Time: 11:40 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!