简体   繁体   中英

I am having this Error: Error #1009: Cannot access a property or method of a null object reference

Im having problems with my Game, i seem to be having this error coming out when i try to move to the next keyframe: at InventoryDemo/collision()[InventoryDemo::frame2:123]

I did a debug and it shows me that the error is somewhere here:

addEventListener(Event.ENTER_FRAME, collision)
function collision(event:Event):void{
 if(girl.hitTestObject(dust))
 {
    mushroom.visible = true;
    mclick.visible = true;
 }

I dont know why the error is coming out

Try this : ( not tested )

addEventListener(Event.ENTER_FRAME, collision)
function collision(event:Event):void{

    if(MovieClip(girl).hitTestObject(dust)) {
        mushroom.visible = true
        mclick.visible = true
    }

}

EDIT

Some tests to verify existance of girl object :

trace(girl is DisplayObject) // gives : true

trace(girl is MovieClip)    // gives : true

trace(girl.hitTestObject)   // gives : function Function() {}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM