我创建了一个movieclip,并使用我的用户定义的类扩展它。现在,如果我想使用该影片剪辑并使用该课程中的属性,我该怎么做呢?
答案 0 :(得分:2)
//declare a variable of appropriate type and initialize it
var myClip:YourClipName = new YourClipName();
//now you can use myClip as if it were a movie clip variable
addChild(myClip);
myClip.x = 10;
//you can also access your custom properties/method with myClip
myClip.myAweSomeMethod(42, "Tadaa");
myClip.prop1 = "Some Value";
更新数组:
//initialize
//n : Total_number_required
public var clips:Array = [];
for(var i:Number = 0; i < n; i++)
{
var clip:YourType = new YourType();
clip.x = 10 * i;
clip.y = 20 * i;
clips.push(clip);
}
//somewhere else in the code
//to get the clip at the kth index
var clip:YourType = YourType(clips[k]);
clip.x = 100;
clip.rotation = 90;