Skip to main content
Inspiring
December 22, 2010
Answered

hitTest - goto target

  • December 22, 2010
  • 1 reply
  • 1684 views

Hey,

I seem to be going ova and ova this code trying to make it work in every situation.

I am trying to get the hit test on 8 targets to goto different frame labels.

Is there a way to set up a target name for each hit test?

//---Array_Chars---//

char.push(lal);

char.push(zim);

char.push(binx);

char.push(jiji);

char.push(dink);

char.push(oli);

char.push(kami);

char.push(alf);

stage.addEventListener(MouseEvent.MOUSE_MOVE,charMove);

function charMove(evt:MouseEvent)

{

addEventListener(Event.ENTER_FRAME, checkcharCollision);

}

function checkcharCollision(event:Event)

{

for (var i:uint=0; i<char.length; i++)

{

if (char.hitTestObject(cur))

{

target code here?

}

}

return;

}

any help or suggestions r welcome

thx pavel

This topic has been closed for replies.
Correct answer

2 different arrays...

first array will hold  the data for  char

second  array will hold the data for targets

they are connected through the index number.

what is the error?  Show your last code

1 reply

December 22, 2010

//---Array_Chars---// and Targets Aray

char.push(lal); targets.push("target1");

char.push(zim); targets.push("target2");

char.push(binx); targets.push("target3");

char.push(jiji);                                        // write every target....

char.push(dink);

char.push(oli);

char.push(kami);

char.push(alf);

stage.addEventListener(MouseEvent.MOUSE_MOVE,charMove);

function charMove(evt:MouseEvent)

{

addEventListener(Event.ENTER_FRAME, checkcharCollision);

}

function checkcharCollision(event:Event)

{

for (var i:uint=0; i<char.length; i++)

{

if (char.hitTestObject(cur))

{

trace(targets);

}

}

return;

}

pa-pavelAuthor
Inspiring
December 22, 2010

hey thx gain for replying...u rock!

but it gives me an error

char.push(lal); targets.push("laylaFrame");

error : access of undefined property targets

im guessing i need to label the targets?

thx pavel

edit*

could it be that i need to create a new array for the targets?

nope still not working ...i dont get how to connect the char(s) with targets?

Correct answer
December 22, 2010

2 different arrays...

first array will hold  the data for  char

second  array will hold the data for targets

they are connected through the index number.

what is the error?  Show your last code