0
votes

My Action Script 2 hitTest isn't working. I've tried searching for the answer, but found nothing. The hitTest isn't responding with the gotoAndStop I've assigned to it. Here is my code:

walkspeed = 25;
jumping = false;
scottjab = false;
crouching = false;
scottslash = false;



scott.onEnterFrame = function(){
if(Key.isDown(Key.DOWN) && !jumping && !scottjab && !crouching){
    this.gotoAndStop("scottCrouch");
    crouching = true;
} else if(Key.isDown(78) && !jumping && !scottjab && !crouching){
    this.gotoAndStop("scottJab");
    scottjab = true;
} else if(Key.isDown(77) && !jumping && !scottjab && !crouching){
    this.gotoAndStop("scottSlash");
    scottslash = true;
} else if(Key.isDown(Key.UP) && !jumping && !scottjab && !crouching){
    this.gotoAndStop("scottJump");
    jumping = true;
} else if(Key.isDown(Key.LEFT) && !jumping && !scottjab && !crouching){
    this._x -= walkspeed;
    this.gotoAndStop("scottWalk");
} else if(Key.isDown(Key.RIGHT) && !jumping && !scottjab && !crouching){
    this._x += walkspeed;
    this.gotoAndStop("scottWalk");
} else if(!jumping && !scottjab && !crouching){
    this.gotoAndStop("scottIdle");
}
} 

ilsa.onEnterFrame = function(){
if(scott.scottJab.pad.hitTest(this)){
    this.gotoAndStop("ilsa Hit");
} else {
    this.gotoAndStop("ilsa Idle");
}
}

The two characters ('scott' and 'ilsa') are also on different layers, if that helps. And there are 4 total scenes in the file.

I appreciate any help.

1
If you try to write trace("hitTest"); after this.gotoAndStop("ilsa Hit"); in your ilsa.onEnterFrame function, what is the result (output)? - helloflash
Nothing seems to happen. What should I do? - Scott
And if you try: trace(scott); trace(scott.scottJab); trace(scott.scottJab.pad); what happens? - helloflash
Again, nothing happens. - Scott
That's normal. You have to put these instructions outside of your ilsa.onEnterFrame function. What is the output? - helloflash

1 Answers

0
votes

Your problem comes from your if statement:

if (scott.scottJab.pad.hitTest(this)) {/* ... */}

The object you are targeting doesn't exist, isn't named or isn't correctly named. Is there an object named pad contained in an object named scottJab itself contained in the object named scott?