flash as脚本 求救!

来源:百度知道 编辑:UC知道 时间:2024/09/22 12:26:53
创建类的脚本:
class Egg{
//定义了两个属性color和weight。
var color:String;
var weight:Number;
//定义了一个方法hatch()。
function hatch(where){
var depth=where.getNextHighestDepth();
where.createTextField("myText"+depth,depth,random(400),random(400),100,20);
where["myText"+depth].text="孵出一只新小鸡!";
}
//定义了构造器函数Egg。
function Egg(eggColor:String,eggWeight:Number){
color=eggColor;
weight=eggWeight;
}
}

里面的 where["myText"+depth].text="孵出一只新小鸡!"

为什么要加个where上去呀? 不明白这里的用意!

function hatch(where){
var depth=where.getNextHighestDepth();
where.createTextField("myText"+depth,depth,random(400),random(400),100,20);
where["myText"+depth].text="孵出一只新小鸡!";
}
////////////////////////////////////////
where 是这个函数的参数,其数据类型在as2中应该是movieClip(影片剪辑),
第2句和第3句的意思是在这个影片剪辑上创建一个文本,其深度为这个影片剪辑中的最高深度
where["myText"+depth].text="孵出一只新小鸡!" 前边的where就是指明文本的路径,即where影片剪辑下,"myText"+depth 文本的text属性为 "孵出一只新小鸡!" 道理和_root.mcName.....一样,指明路径。

where是那个hatch方法需要的参数啊.
你可以把那个where随便改,改成"这里"或者"here",都不会出错的,如果要改,就得全部一起改的吧.

这个where居然没有定义数据类型啊.大约会代表一个Object吧,这代码太乱了噢.

你试试?