PDA

View Full Version : Roll Out Scripting Part 2


Heimdall
11-20-2003, 08:53 PM
Need some help from some scripting gurus:

I have a button,

It has a rollOver command, a rollOut command, and finally an onRelease command.

Here's the script:

on (rollOver) {
gotoAndPlay ("web");
}
on (rollOut) {
gotoAndPlay ("webout");
}
on (release) {
gotoAndPlay ("webhit");
}

Challenge:
I want to keep the rollOut action from executing if the "release" command executes.

Flash 5 Mac OSX.2

I'll repost this at the top.


-Heimdall

Ian Jones
11-21-2003, 01:13 AM
Correct me if I get my syntax wrong (cos I'm between a lot of languages atm) but here goes:


onClipEvent (load) {
allowRollout=true;
}

on (rollOver) {
allowRollout=true;
gotoAndPlay ("web");
}

on (rollOut) {
if (allowRollout==true) {
gotoAndPlay ("webout");
}
}

on (press) {
allowRollout=false;
}

on (release) {
gotoAndPlay ("webhit");
}

Ian Jones
11-21-2003, 01:27 AM
I thought I'd better explain that...

The Load event is just to create and initialize a variable.

We are using a variable as a switch that we turn off and on to control the rollOut event. If we wish to allow the rollOut event to occur then we set the variable 'allowRollout' to true.

When a rollOut event occurs, it will only execute the gotoAndPlay if 'allowRollout' is true.

We turn 'allowRollout' to false whenever we don't want the rollOut event to occur. In this case I have added this to the onPress event. Why? Well if we had put it in the onRelease event it is possible that the user can actually click, hold the mouse button down whilst moving the cursor off the button and then finally releasing. This would trigger the rollOut event before the onRelease event. You have to make things completely bulletproof when it comes to users. The onPress event occurs when the user first clicks and before they release and therefore is exactly what we need.

I hope that helps.

Ian Jones
11-21-2003, 01:35 AM
ARG! I forgot to mention one last thing.

We need to reset the 'allowRollout' variable to true in order for possible rollOut events to occur again in the future. We can do this by setting the variable to true within the rollOver event.

Heimdall
11-21-2003, 06:50 PM
AHA! Thanks Ian.

-Heimdall

CGTalk Moderation
01-16-2006, 05:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.