Skip to main content
Participant
July 26, 2017
Question

desperate! need help with roll_over & roll_out functions

  • July 26, 2017
  • 2 replies
  • 406 views

I desperately need help!!!

This is my very first game: http://www.newgrounds.com/portal/view/696943

It's a dark point 'n click game.

Unfortunately there's a problem with the roll_over and roll_out functions. I really hope someone is going to give me an easy solution. I am pretty new to coding and I seem to be pretty dumb, because I already finished the whole game with hundreds of complex movie clips...

The problem is this:

In many movie clips there's an invisible button, eg in frame 1: if you roll_over a man there's an invisible button that gets you to frame 3 where options appear, eg "talk". (see the attached pic)

In frame 3 there's the same invisible button. When you roll_out you go back to frame 1. Also there's the button "talk", when you roll_out you also get to frame 1. (see the attached pic)

Now, when people roll_out too quickly the whole thing stucks at frame 3 and you have to roll_over and _out again to get back to frame 1.

Here's the code in frame 1:
stop();

InvisibleMan.addEventListener(MouseEvent.ROLL_OVER,IMan);

function IMan(event:MouseEvent):void
{
gotoAndPlay(3);
}

And this is the code in frame 3:

stop();

InvisibleMan.addEventListener(MouseEvent.ROLL_OUT,OutMan);

function OutMan(event:MouseEvent):void
{
gotoAndPlay(1);
}

ManTalk.addEventListener(MouseEvent.ROLL_OUT,OutManTalk);

function OutManTalk(event:MouseEvent):void
{
gotoAndPlay(1);
}

And I have this code everywhere, so hundreds or even thousands of times...

I already tried to increase the fps. It helps a little but I can't increase it more because otherwise all the animations (txts, et cetera) would be too fast and it would take me weeks to make them slower...

The problem doesn't occur all the time, only when you roll_out very quickly.

Can someone pls help?

This topic has been closed for replies.

2 replies

Inspiring
July 29, 2017

These kind of errors kill me. And I'm sorry, but I don't remember exactly what my solutions were to this. However, I do know that it can be helpful to have a DRAG_OUT function that mimics the ROLL_OUT function.

I also was able to solve some of my issues by using the 'stage' variable as such:

stage.ManTalk.addEventListener(MouseEvent.ROLL_OUT,OutManTalk);

But I don't remember exactly the cases that made that work better. Best of luck.

kglad
Community Expert
Community Expert
July 26, 2017

all that code should be in frame 1.

p.s  you only need one rollout function.  both rollout listeners should call it.  and you may want to use something like

function rolloutF(e:MouseEvent):void{

if(this.currentFrame!=?){

this.gotoAndPlay(1);

}

}

Participant
July 27, 2017

Thanks for your respond!

How should all code be in frame 1? When I want frame 1 to appear blank for the player unless he rolls over the man?

However I tried your code and it works better than mine! But strangely there are still some cases where it's stuck in frame 3 when you roll out of both buttons. Definitely less than before but it still occurs... Can you explain why?

kglad
Community Expert
Community Expert
July 27, 2017

i can't see your setup so i can't explain why.  i don't even know if you moved all your code to the first keyframe that contains the rollover objects.

to code for an object that you don't want seen, either:

1. make its alpha property 0 (if you want it to respond the mouse), or

2. make its visible property false (if you want it to not respond)