Search code examples
flashadobe

FLASH , TypeError: Error #1009: Cannot access a property or method of a null object reference. at pedangan_fla::MainTimeline/asd()


null object is pemukul

why I get this error ,

TypeError: Error #1009: Cannot access a property or method of a null object reference. at pedangan_fla::MainTimeline/asd()

this my code :

trace(pemukul)
var pemukul:MovieClip = test.getChildByName("pemukul") as MovieClip;
stage.addEventListener(Event.ENTER_FRAME,asd)
function asd(e:Event){
    if(pemukul.hitTestObject(musuh)){
        musuh.visible=false
    }
}

Solution

  • after recreating a simple scene with your code, I didn't get your error. When you initially trace pemukul, do you get [object MovieClip] or do you get null?

    I can reproduce an error when the test clip didn't contain a child named pemukul - can you double check to make sure a child of that name exists?