for(var i:uint=0; i
This code causes the type mis-match error at compile, because getChildAt() method returns a DisplayObject.
위 코드는 컴파일 시에 다음과 같은 타입 미스매치 에러를 냅니다. 왜냐하면 getChildAt()메소드는 DisplayObject 객체를 리턴하기 때문이죠.
1118: Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type flash.display:MovieClip.
To avoid the compile error, you can cast the returned value as MovieClip like this.
이러한 컴파일 에러를 회피하기 위해 다음과 같이 리턴된 값을 MovieClip로 캐스팅합니다.
var mc:MovieClip = MovieClip(getChildAt(i));
You can also use "as".
또는 "as"를 사용할 수 있습니다.
var mc:MovieClip = getChildAt(i) as MovieClip;
[태그:] casting
-
use “as” to avoid type mis-match error