티스토리 뷰
패키지 : flash.errors
클래스 : public dynamic class IllegalOperation_error
메서드 : IllegalOperation_error(message:String = "")
구현되지 않거나 현재의 사용이 구현 범위에서 벗어나는 경우 IllegalOperation_error 예외가 발생합니다.
package {
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.errors.IllegalOperationError;
public class IllegalOperation_errorExample extends Sprite {
public function IllegalOperation_errorExample() {
var child:Sprite = new Sprite();
try {
addChild(child);
}
catch(e:IllegalOperation_error) {
trace(e);
}
}
public override function addChild(child:DisplayObject):DisplayObject {
throw new IllegalOperation_error("addChild cannot be performed on the IllegalOperation_errorExample class");
}
}
}
10 : addChild로 child를 추가하였지만
17 : override로 addChild를 재정의하였다. (override 메서드를 쓸 때, 리턴값도 일치해야함에 유의한다.)
throw new 로 IllegalOperation_error 에러메세지를 등록하고
12 : try 에서 실패한 구문이 catch로 잡아내어 trace로 추적하여 결과가 전송된다.
결과 : Error: addChild cannot be performed on the IllegalOperation_errorExample class
'■ 플래시 ■ > Adobe ActionScript3.0' 카테고리의 다른 글
| interface - 인터페이스 2 (0) | 2013.10.16 |
|---|---|
| interface - 인터페이스1 (0) | 2013.10.16 |
| flashVars값 넘기기 - 제이쿼리, 오브젝트이용 (0) | 2013.10.16 |
| DisplayObject 클래스 구조 (0) | 2013.10.16 |
| 구글Tweener - 원본의 color속성 되돌아오기 (0) | 2013.10.16 |
댓글