Copy link to clipboard
Copied
Obviously as you can see from this clip the Hit and Miss is not corresponding to the actual event on the stage. why? It works only if I give the objects instance name, but not working when using the var name. why?
here's the code:
import flash.events.Event;
var gball: SmallGreenBall1_T = new SmallGreenBall1_T();
var bucket: allBuckets = new allBuckets();
this.addEventListener(Event.ENTER_FRAME, handleCollision)
function handleCollision(evt: Event): void {
if (gball.hitTestObject(bucket)) {
output_txt.text = "HIT"
} else {
output_txt.text = "MISS"
}
}
maybe you just need to remove some code. if you have a gball on-stage and a bucket on stage, use:
import flash.events.Event;
this.addEventListener(Event.ENTER_FRAME, handleCollision)
function handleCollision(evt: Event): void {
if (gball.hitTestObject(bucket)) {
output_txt.text = "HIT"
} else {
output_txt.text = "MISS"
}
}
p.s. if that fails, is gball time-line tweened?
Copy link to clipboard
Copied
bucket's at 0,0 though you can't see it because you failed to add it to the stage.
same with gball but you must be doing something with one or both of those two for the textfield text to change.
Copy link to clipboard
Copied
can you put it in the code for me please?
Copy link to clipboard
Copied
maybe you just need to remove some code. if you have a gball on-stage and a bucket on stage, use:
import flash.events.Event;
this.addEventListener(Event.ENTER_FRAME, handleCollision)
function handleCollision(evt: Event): void {
if (gball.hitTestObject(bucket)) {
output_txt.text = "HIT"
} else {
output_txt.text = "MISS"
}
}
p.s. if that fails, is gball time-line tweened?
Copy link to clipboard
Copied
OK got it. I had to addChild it instead of pre position them on stage.
Thanks for your help.
Copy link to clipboard
Copied
you're welcome.
p.s when using the adobe forums, please mark helpful/correct responses, if there are any.