Im looking for an expert opinion on this, I have been working on a flash interactive map that allows you to click a state - which changes an html select drop down form to a different state depending upon which state you click.
I have created a function for each state like this:
ExternalInterface.call("selectIllinois");
Its a lot of code and very repetitive, but it works. Im wondering if someone looks at my code and can see a quicker way to get it done right away or can suggest a different way. I wanted to know if you can pass variables along using ExternalInterface.call ? So then I could call a function and pass a variables, that my javascript looks for and changes the select based up that variable?
Here is the rest of my code:
JavaScript -
function selectWashington()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Washington"
}
function selectOregon()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Oregon"
}
function selectCalifornia()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="California"
}
function selectNevada()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Nevada"
}
function selectUtah()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Utah"
}
function selectColorado()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Colorado"
}
function selectMinnesota()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Minnesota"
}
function selectTexas()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Texas"
}
function selectMissouri()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Missouri"
}
function selectWisconsin()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Wisconsin"
}
function selectIllinois()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Illinois"
}
ActionScript -
import flash.external.*;
import mx.transitions.*;
// washington
map.wash.onRollOver = function() {
this.gotoAndStop("onRollover");
new Tween(this, "_xscale", Regular.easeOut, this._xscale, 200, 0.3, true);
new Tween(this, "_yscale", Regular.easeOut, this._yscale, 200, 0.3, true);
};
map.wash.onRollOut = function() {
this.gotoAndStop("onRollout");
new Tween(this, "_xscale", Regular.easeOut, this._xscale, 100, 0.3, true);
new Tween(this, "_yscale", Regular.easeOut, this._yscale, 100, 0.3, true);
};
map.wash.onRelease = function() {
ExternalInterface.call("selectWashington");
};
// oregon
map.ore.onRollOver = function() {
this.gotoAndStop("onRollover");
new Tween(this, "_xscale", Regular.easeOut, this._xscale, 200, 0.3, true);
new Tween(this, "_yscale", Regular.easeOut, this._yscale, 200, 0.3, true);
};
map.ore.onRollOut = function() {
this.gotoAndStop("onRollout");
};
map.ore.onRelease = function() {
ExternalInterface.call("selectOregon");
};
// california
map.california.onRelease = function() {
ExternalInterface.call("selectCalifornia");
};
map.california.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.california.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// nevada
map.nevada.onRelease = function() {
ExternalInterface.call("selectNevada");
};
map.nevada.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.nevada.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// utah
map.utah.onRelease = function() {
ExternalInterface.call("selectUtah");
};
map.utah.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.utah.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// colorado
map.colorado.onRelease = function() {
ExternalInterface.call("selectColorado");
};
map.colorado.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.colorado.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// texas
map.texas.onRelease = function() {
ExternalInterface.call("selectTexas");
};
map.texas.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.texas.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// minnesota
map.minnesota.onRelease = function() {
ExternalInterface.call("selectMinnesota");
};
map.minnesota.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.minnesota.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// missouri
map.missouri.onRelease = function() {
ExternalInterface.call("selectMissouri");
};
map.missouri.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.missouri.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// wisconsin
map.wisconsin.onRelease = function() {
ExternalInterface.call("selectWisconsin");
};
map.wisconsin.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.wisconsin.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// illonois
map.illinois.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.illinois.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.illinois.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// tennessee
map.tenn.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.tenn.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.tenn.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// pennsylvania
map.penn.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.penn.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.penn.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// michigan
map.michigan.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.michigan.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.michigan.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// ohio
map.ohio.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.ohio.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.ohio.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// north carolina
map.northcarolina.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.northcarolina.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.northcarolina.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// alabama
map.alabama.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.alabama.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.alabama.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// georgia
map.georgia.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.georgia.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.georgia.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// florida
map.florida.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.florida.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.florida.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// maryland
map.maryland.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.maryland.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.maryland.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// delaware
map.tenn.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.de.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.de.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// newjersey
map.nj.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.nj.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.nj.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// connecticut
map.conn.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.conn.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.conn.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// rhodeisland
map.rhodeisland.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.rhodeisland.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.rhodeisland.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// new hampshire
map.nh.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.nh.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.nh.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// new york
map.ny.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.ny.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.ny.onRollOut = function() {
this.gotoAndStop("onRollout");
};
// mass
map.mass.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.mass.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.mass.onRollOut = function() {
this.gotoAndStop("onRollout");
};
Thank you in Advance!
Jake