본문 바로가기
생활일기/tip tech

TypeError: Error #1009

by 신일석 2009. 6. 23.
액션스크립트에서 스테이지를 동적으로 불러 사용하고자 할때 다음과 같은 에러 메세지를 만날수 있다.



TypeError: Error #1009: Cannot access a property or method of a null object reference.

at ContentLayer()

at bigiLand_fla::MainTimeline/frame1()



이런 메세지는 무비클립 등을 사용할 경우에도 만날 수 있는데



ADDED_TO_STAGE를 이용하여 해결할 수 있다.



여기를 보면 문제 해결전과 후의 소스가 있는데

변화(아래 녹색)의 차이를 보고 같은 방식으로 적용하면 해결할 수 있다.

public class SlideShowEngine extends Sprite {



public function SlideShowEngine() {



addEventListener( Event.ADDED_TO_STAGE, onAdded );

}




function onAdded( event:Event ):void {

removeEventListener( Event.ADDED_TO_STAGE, onAdded );




var _slideshow:SlideShow;

var pFile:String = stage.loaderInfo.parameters.slideshow;

if (!pFile) pFile = “slides.xml”;

var pProperties:SlideProperties = new SlideProperties(1020, 680);


그외 도움이 될만한 곳



  • http://curtismorley.com/2007/08/15/flash-cs3-flex-error-1009-cannot-access-a-property-or-method-of-a-null-object-reference/


  • http://livedocs.adobe.com/flex/201/langref/flash/events/Event.html