Is there a way to optimise this code into something more compact?
This is for an interactive map that im busy with, and there is still a lot of coding left to do!
The instance loc_dot is a mc with a pulsing circle that hovers over the corresponding area on the displaying the name of the countrywhen the user hovers over Angola for instance.
stop();
// Location Pointer Propertiesimport fl.transitions.Tween;
import fl.transitions.easing.*;
loc_dot.alpha = 0;
var inTween:Tween;
var outTween:Tween;
loc_dot.mc_loc_txt.loc_txt.text = "";
addEventListener(MouseEvent.MOUSE_OVER, showLocDot);
addEventListener(MouseEvent.MOUSE_OUT, hideLocDot);
function showLocDot(event:MouseEvent):void
{
switch (event.target)
{
case btn_ngla :
loc_dot.mc_loc_txt.loc_txt.text ="ANGOLA";
loc_dot.x = 445;
loc_dot.y = 445;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_btswna :
loc_dot.mc_loc_txt.loc_txt.text ="BOTSWANA";
loc_dot.x = 463;
loc_dot.y = 475;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_cote :
loc_dot.mc_loc_txt.loc_txt.text ="COTE D'IVOIRE";
loc_dot.x = 383;
loc_dot.y = 383;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_ethi :
loc_dot.mc_loc_txt.loc_txt.text ="ETHIOPIA";
loc_dot.x = 505;
loc_dot.y = 380;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_ghna :
loc_dot.mc_loc_txt.loc_txt.text ="GHANA";
loc_dot.x = 395;
loc_dot.y = 382;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_lshto :
loc_dot.mc_loc_txt.loc_txt.text ="LESHOTO";
loc_dot.x = 473.5;
loc_dot.y = 497.5;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_madg :
loc_dot.mc_loc_txt.loc_txt.text ="MADAGASCAR";
loc_dot.x = 524;
loc_dot.y = 465;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_mali :
loc_dot.mc_loc_txt.loc_txt.text ="MALI";
loc_dot.x = 390;
loc_dot.y = 350;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_moz :
loc_dot.mc_loc_txt.loc_txt.text ="MOZAMBIQUE";
loc_dot.x = 491;
loc_dot.y = 465;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_nam :
loc_dot.mc_loc_txt.loc_txt.text ="NAMIBIA";
loc_dot.x = 445;
loc_dot.y = 475;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_rus :
loc_dot.mc_loc_txt.loc_txt.text ="RUSSIA";
loc_dot.x = 595;
loc_dot.y = 215;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_sdn :
loc_dot.mc_loc_txt.loc_txt.text ="SUDAN";
loc_dot.x = 480;
loc_dot.y = 360;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_swa :
loc_dot.mc_loc_txt.loc_txt.text ="SWAZILAND";
loc_dot.x = 483;
loc_dot.y = 489;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_uae :
loc_dot.mc_loc_txt.loc_txt.text ="UAE";
loc_dot.x = 545;
loc_dot.y = 333;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_zam :
loc_dot.mc_loc_txt.loc_txt.text ="ZAMBIA";
loc_dot.x = 470;
loc_dot.y = 454;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
case btn_zim :
loc_dot.mc_loc_txt.loc_txt.text ="ZIMBABWE";
loc_dot.x = 480;
loc_dot.y = 465;
inTween = new Tween(loc_dot,"alpha",None.easeNone,0,1,1,true);
break;
}
}
function hideLocDot(event:MouseEvent):void
{
switch (event.target)
{
case btn_ngla :
case btn_btswna :
case btn_cote :
case btn_ethi :
case btn_ghna :
case btn_lshto :
case btn_madg :
case btn_mali :
case btn_moz :
case btn_nam :
case btn_rus :
case btn_sdn :
case btn_swa :
case btn_uae :
case btn_zam :
case btn_zim :
outTween = new Tween(loc_dot,"alpha",None.easeNone,1,0,1,true);
break;
}
}