Skip to main content
July 1, 2006
Question

Need some help with roll over buttons

  • July 1, 2006
  • 2 replies
  • 162 views
I've imported a map from Illustrator and I want regions of it to light up when rolled over. I spread the sections of the map to various layers, converted each one to a button and now I've added this code to each one:

on (rollOver, rollOut) {
sangabriel.onRollOver = function() {
this._alpha = 75;
};
sangabriel.onRollOut = function() {
this._alpha = 100;
};
}
on (release) {
getURL("");
}

Since the stage is white, the map sections "light up" on rollover. The url's haven't been added yet.

Anyway, it works except for one thing. When the mouse enters a map section the first time I get no reaction. However on entering a section (11 in all) a second time, it behaves properly and "lights up." After that they all work perfectly. But why do I have to roll over these twice before they work each time I test the graphic?

Do I need to set some varables? Enable something?
This topic has been closed for replies.

2 replies

July 2, 2006
Thanks very much, that was it. Everything is working smoothly now.
Inspiring
July 1, 2006
You mixed up two ways of assigning events here: way 1 is adding
on(rollOver){ ... }
to a movieclip or button instance, way 2 is using
instancename.onRollOver = function(){ ... }
in the timeline. Way 2 is the dynamic way of assigning events, so you use the on(xxx) event to assign the onRollOver event dynamically. That's why it only works in the 2nd rollOver: in the 1st, the events get assigned, in the 2nd, they execute.

So you should decide which way to use, either this in the button's actions:

on (rollOver) {
this._alpha = 75;
}
on(rollOut) {
this._alpha = 100;
}
on(release) {
getURL("");
}

or this in a timeline frame:

sangabriel.onRollOver = function() {
this._alpha = 75;
};
sangabriel.onRollOut = function() {
this._alpha = 100;
};
sangabriel.onRelease = function() {
getURL("");
};

cheers,
blemmo