本帖最后由 zhoulishun 于 2016-1-4 22:25 编辑
类文件代码 类文件名Person
package
{
import flash.display.MovieClip;
public class Person extends MovieClip
{
public var fName:String;
public var Name:String;
public var age:int;
public function Person();
{
fName = "san";
Name = "Zhang";
age = 20;
// constructor code
};
public function setInfo(myfName:String,myNa:String,myAge:int)
{
fName = myfName;
Name = myNa;
age = myAge;
}
public function self_introduction()
{
return ("Hello,my name is"+Name+" "+fName+" and I'm "+age+" years old.");
}
}
}
主场景时间轴代码
var newPerson:Person=new Person();
newPerson.setInfo("立顺","周",45);
newPerson.self_introduction();
编译器报错
fName Name age 这三个变量未定义
请高手指点迷津 |