First of all hello!
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