-
1. Re: hitTestObject causing loop in AS3
Ned Murphy Jul 15, 2010 12:33 PM (in response to T_Townrampage)I didn't really focus on trying to understand the code, but if you have ENTER_FRAME listeners assigned, then you might want to remove them once the hitTestObject bit occurs, otherwise they will continue firing.
-
2. Re: hitTestObject causing loop in AS3
T_Townrampage Jul 15, 2010 12:40 PM (in response to Ned Murphy)Thanks Ned, how would I remove it?
Im a newbie to AS3, and I come to this forum first to learn form the masters!
-
3. Re: hitTestObject causing loop in AS3
T_Townrampage Jul 15, 2010 1:34 PM (in response to Ned Murphy)I have tried removing the ENTER_FRAME with no luck, it is still looping.
Im probably doing it wrong, here is my code
var rewind:Boolean = false;
trig.addEventListener(Event.ENTER_FRAME, enter_frame);
rolly.addEventListener(Event.ENTER_FRAME, enter_frame);function enter_frame(event:Event):void{
if (trig.hitTestObject(slider_mc)) {
removeEventListener(Event.ENTER_FRAME,enter_frame)
rolly.play();
rewind = false;
}else{
rewind = true;
}
}
rolly.myBT.addEventListener(Event.ENTER_FRAME,revFrame);
function revFrame(e:Event):void{
if(rewind == true){
rolly.prevFrame();
}
}Any thoughts?
-
4. Re: hitTestObject causing loop in AS3
T_Townrampage Jul 15, 2010 2:32 PM (in response to Ned Murphy)I got it to work.
The loop is stopped!!
But when the hitTestObject is broken or when the mc's are not touching the mc should reverse, like on an old school rollOut.
What am I doing wrong??
var rewind:Boolean = false;
rolly.addEventListener(Event.ENTER_FRAME, enter_frame);
function enter_frame(event:Event):void{
if (trig.hitTestObject(slider_mc)) {
rolly.removeEventListener(Event.ENTER_FRAME,enter_frame)
rolly.play();
rewind = false;
}else{
rewind = true;
}
}
rolly.addEventListener(Event.ENTER_FRAME,revFrame);
function revFrame(e:Event):void{
if(rewind == true){
rolly.prevFrame();
}
} -
5. Re: hitTestObject causing loop in AS3
Ned Murphy Jul 15, 2010 4:31 PM (in response to T_Townrampage)I'm still trying to avoid understanding the code If you're always going to have an ENTER_FRAME active then maybe you can combine them into one.
rolly.addEventListener(Event.ENTER_FRAME, enter_frame);
function enter_frame(event:Event):void{
if (trig.hitTestObject(slider_mc)) {
if(rolly.currentFrame < rolly.totalFrames)rolly.play();
}
} else {
rolly.prevFrame();
}
} -
6. Re: hitTestObject causing loop in AS3
T_Townrampage Jul 15, 2010 9:19 PM (in response to Ned Murphy)You nailed it!
Thank you my friend.


