I just started using flash so this might be a simple thing so please be patient.
I’m doing a project were I have a map and you can click the places on the map and the info appears. I could manage to link every button_btn to every info_mc but that would take forever, so I tried to make a function that would read the buttons name and redirect to the info_mc itself. However since the name is being converted to string when I change from name_mc to name_info it is not redirecting. Here is the code.
winterfell_info.visible = false;
map.winterfell_btn.doubleclickEnabled = true;
map.winterfell_btn.mouseChildren = doubleClickEnabled;
map.winterfell_btn.addEventListener(MouseEvent.DOUBLE_CLICK, show_clicked);
function show_clicked(e:MouseEvent):void{
var get_name = e.currentTarget.name;
var open_info_string = get_name.slice(0,-3) + "info";
//I've tried some things here but nothing is working for me.
var open_info = stage.getChildByName(open_info_string);
open_info.visible = true;
}
Any help would be very much appreciated, thank you.
And if you wondering yes its a map for Game of Thrones.
Remove quotes around “open_info_string”, as a first measure, and change the capital S in that string to normal one “s”, because Actionscript is case sensitive.
Then, if it wouldn’t work at once, insert a
trace(open_info_string);before you try to reach the movie clip, to find out whether it was cropped correctly.