2010-01-21 3 views
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; 
+0

myClip._x = 10; ? –

+0

AS2에서는 @Richard'_x', AS3에서는'x'입니다. OP는 언어 버전을 지정하지 않았으므로 AS3을 사용했습니다 (더 편안함). – Amarghosh

+0

답장을 보내 주셔서 감사합니다 @Amarghosh 내가 지금 직면하고있는 문제는 예를 들어이 무비 클립의 인스턴스를 10 개 만들어야하는 경우입니다. 개별적으로 어떻게 참조합니까? –

관련 문제