March 2010
M T W T F S S
« Feb   Apr »
1234567
891011121314
15161718192021
22232425262728
293031  

Parameters of function

Please look to the simple code below:

function myFunction(a:Number, b:Number):Number
{
var rez:Number;
rez=a+b;
return (rez);
}

var sum1:Number=myFunction(1,2);
var sum2:Number=myFunction(4,3);
var sum3:Number=myFunction(10,5);

trace(sum1);
trace(sum2);
trace(sum3);

There you can see parameters (a:Number, b:Number) of function myFunction. If you will use it then you can change your variable ‘rez’ any time;) Do it with:

var sum1:Number=myFunction(1,2);
var sum2:Number=myFunction(4,3);
var sum3:Number=myFunction(10,5);

As i right clear this is the main idea of function parameters:)

Here result [...]

What mean word 'return' in the end of function?

I saw word ‘return’ a lot in the end of function but just now i find info what does it mean:)
So i created simple code:

function myFunction()
{
var a:int=2;
var b:int=3;
var c:int;
c=a+b;
return (c);
}

var myVariable:int=myFunction();
trace(myVariable);

Here i created simple function myFunction and in the end of body myFunction() you can see command ‘return (c)’. So its mean i want get [...]