第21节 方法重载

来源:互联网 发布:51黑单片机论坛作品 编辑:程序博客网 时间:2024/04/28 03:03

一、hello.as

package {import flash.display.Sprite;public class hello extends Sprite{public function say(...foo):*{//参数不确定,我们写...foo,  返回值不确定我们写*if (foo.length == 1){trace("a");}else if (foo.length==2){trace("b");}}}}

二、创建21.fla文件,在帧中添加脚本

var aoo:hello=new hello();aoo.say(12);//一个参数,输出aaoo.say(1,2);//二个参数,输出b



原创粉丝点击