I'm creating a US map in flash where the states highlight when you rollover them and then when clicked stay highlighted and display contact information until another state is clicked.
I have most of it working, but I cannot get the states to stay highlighted when clicked. I'm trying to create
a variable that says if the mouse has been clicked on a state and then a function that says if its clicked put the movie of the state on frame 2 (highlighted) and if not go back to white.
here is the code on the actionscript layer:
var clickState = "off";
function clearInformation () {
this.proavWA._alpha = 0;
this.proavCA._alpha = 0;
this.proavOR._alpha = 0;
this.proavNV._alpha = 0;
this.proavID._alpha = 0;
this.proavMT._alpha = 0;
this.proavWY._alpha = 0;
this.proavCO._alpha = 0;
this.proavAZ._alpha = 0;
this.proavNM._alpha = 0;
}
function clickChecker() {
if (clickState = "off") {
this[rolledState].gotoAndS
top(1);
trace ("its working");
} else {
this[rolledState].gotoAndS
top(2);
trace ("its working part 2");}
}
function hoverRemove () {
this[selectedState].gotoAn
dStop(1);
}
And here is what the action script for the movie clip of the state of washington looks like:
on (rollOver) { /* highlight state and put grab name for clickChecker */
gotoAndStop(2);
_global.rolledState = this._name;
}
on (rollOut) { /* check to see if state should stay highlighted */
_root.clickChecker();
trace (clickState);
}
on (press) { /* remove contact box and color from previous clicked state */
_root.clearInformation();
_root.hoverRemove();
}
on (release) { /* set name and contact info then make state stay highlighted */
_root.states = "Washington";
_root.proavWA._alpha = 100;
_global.clickState = "on";
_global.selectedState = this._name;
}
using traces it seems like the variable starts as undefined even though I tried to set it. The function always executes the first part of the if statement never the else. If i set it to off when the state gets rolled over it doesnt make a difference.
you can view how the swf works here:
http://www.kylejlarson.com/chief/map/map.htmlso far i've just been working with oregon and washington so the other states aren't set up yet
Start Free Trial