RollOver map loading external text

First of all hello! :beer:

This is my first post, iā€™ve only been learning flash for about 3 weeks and iā€™m really starting to enjoy it. Unfortunately iā€™ve run into a bit of a problem on the project which inspired me to first learn flash in the first place.

Iā€™ve been asked to create a simple (if only) interactive map. Essentially, when the mouse hovers over a particular state/town/borough etc. Its name will appear in a small pop-up label which follows the mouse around.

So far so good! I have managed to create the pop-up label and the State/borough outlines (currently just represented by oval and rectangular buttons). The label follows the mouse and its text is dynamically linked to the Stateā€™s instance name using ā€œthis._nameā€, with the labelā€™s alpha visibility controlled through ā€œtargetAā€:

state1_mc.onRollOver = state2_mc.onRollOver = function() { 
myName = this._name;
statename_mc.statename_txt.text = myName; 
statename_mc.targetA = 100;
}

However, it seems messy to have to use the ā€œstate1_mc.onRollOver = state2_mc.onRollOver = state3_mc.onRollOverā€¦ā€. Is there a way to avoid this?

The next request is that upon clicking on the different States, a box will appear which displays more detailed information such as text and images. This is proving very difficult!:huh:

My current solution is to include the following code on each Stateā€™s movie clip and then change the external variable name which is being called:

on (release) {
 infoText = new LoadVars();
 infoText.load ("externaltext.txt")
 infoText.onLoad = function (success) {
 if (success) {
            // trace(success);
            mainText_mc.mainText_txt.text = this.state1;
        }
    };
}

In the above extract ā€œstate1ā€ is the variable held in the externaltext.txt file and mainText_txt is the dynamic text field which appears to the side of the map to display the detailed info.

The thing is, this all seems to work ok, but again it seems rather daft to have to repeat and modify this code for every State.

What i want to know is: is there a way to put code in the main action script frame, which will automatically call-up the relevant variable from an external text depending on which Sate (movie clip or button) is clicked on?

I have tried naming the variables within my external text file with the same instance name as the Stateā€™s and tried to populate the text field using this._name but that hasnā€™t worked (eg. if mouse is over mc1, then when clicked load variable mc1 from externaltext.txt).

Iā€™m sure thereā€™s some simple solution, but as a beginner to all this iā€™ve not managed to find it yet (despite alot of searching). Any help or directions to a tutorial would be much appreciated (especially if theyā€™re aimed at beginners!)

Kind regards

DFG
:slight_smile: