Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling Rollout Question

Status
Not open for further replies.

skrause

Programmer
Feb 10, 2001
18
US
Greetings:

I am trying to create a button (soon to be buttons) where I'd like to control what happens on rollout off the button. For example, my button is a simple rectangle. If I rollOff either the left, Top , or right side of the button, I want to go to another frame. If I rolloff the bottom, I want to remain in the current frame.

I thought I could use _xframe and _yframe to manage this in the following way...

button1 - button name
the upper left coords within the movie is x,y
the size of the button is x1 wide, y1 tall

on (rollOut) {
if (button1._xmouse < x || button1._xmouse > (x+x1) || button1._ymouse < y ) {
gotoAndStop (1);
} else {
stop ();
}
}

However, this is not working. I have just started to use ActionScript, so if I am missing something elementary, please be gentle.

Thanks,
Steve
 
There might be a much easier way to achieve the effect you're after. Instead of worrying about the rollOut state of your current button and all of the conditional logic that implies in your example you could try this...

Place another new button just above the button in your example, since a button can be any shape this could surround your current one on the top, left and right sides as you stated. Make this button invisible (i.e. the shape only exists in the &quot;hit&quot; area and the other frames are blank). Use the rollOver properties of this new button to redirect your movie.

In other words, when your user rolls out of the first button nothing happens but as soon as they roll over the new button, which is directly adjacent, you can trigger the actions.

on(rollOver){
gotoAndStop(1);
}


or whatever. This will save a load of tortuous if.. else stylescripting and should still provide the results you need.
 
Here's an actionScript variant that would also solve the problem if you're attached to the idea of using rollOut, but it's definitely more involved than the method above!

You'll need to set up three variables - leftEdge, rightEdge and topEdge - which give the position of your button's respective boundaries on the stage (it's often easiest to declare all of these variables in the first frame of your movie on the root layer, that way you can get to them from anywhere just by using _root.variableName).

The checking script would then be..

on (rollOut) {
if (_root._xmouse>_root.rightEdge || _root._xmouse<_root.leftEdge || _root._ymouse<_root.topEdge) {
gotoAndStop (1);
} else {
stop ();
}
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top