Study/Actionscript 3.02009. 12. 6. 17:52

Implicit coercion of a value with static type

 

자주 보게 되는 에러들이다

 

1118: Implicit coercion of a value with static type flash.display:DisplayObjectContainer to a possibly unrelated type flash.display:MovieClip.
1118: Implicit coercion of a value with static type Object to a possibly unrelated type loadLayer.

 

이 에러들은 반환되는 값이 명확하지 않기때문에 생기기때문에 명확하게 해주자

 

_layer_block.addEventListener("CompleteLoadLayer", LoadClipInfo);

 

private fuction LoadClipInfo(e:Event):void

trace(_layer_block);  //결과 [object loadLayer]

trace(e.target);         //결과 [object loadLayer]

trace(e.target == e.target);   //결과 true

 

하지만

아래함수로 호출하게 되면

loadload(_layer_block);          //결과 이상없음

loadload(e.target);                 //결과 . 1118에러

 

private function loadload(layer:loadLayer):void

 

e.target으로 호출하면 에러가 난다

그럴땐 강제로 반환되는 형을 맞춰 주자

loadload(e.target as loadLayer);




Posted by chacolina