AS3.0函数定义的方法

时间:2023-03-09 04:55:12
AS3.0函数定义的方法

在AS3.0中函数的定义有两种方法:

函数语句定义法:

function 函数名(参数1:参数类型,参数2:参数类型):返回值类型{

  函数折行的语句

}

function testAdd(a:int,b:int):int
{
return a+b;
}

函数表达式定义法:就是把整个函数以一个变量的形式来定义。

var 函数名:Function = function(参数1:参数类型,参数2:参数类型):返回值类型{

  函数折行的语句

}

var testAdd:Function = function(a:int,b:int):int{
return a+b;
}

相关文章