Hi there,
Thanks a lot for taking the time to try to help me!
Here’s my problem;
I have a lot of countries, and i want to make functions for each country, here’s working code.
united_kingdom.onRollOver = function() {
animateCountry(“united_kingdom”)
}
algeria.onRollOver = function() {
animateCountry(“algeria”)
}
australia.onRollOver = function() {
animateCountry(“australia”)
}
This works fine, but with a huge list of countries and needing to do rollOut and press etc, i’d like to make the function creation dynamic so i’ve tried…
var countryList = new Array ()
countryList[0]=“united_kingdom”
countryList[1]=“algeria”
countryList[2]="australia
for (j=0;j<countryList.length;j++) {
// set the countrys roll over state
this[countryList[j]].onRollOver = function() {
animateCountry(countryList[j])
}
}
it makes all the correct roll over functions fine, but whenever it executes animateCountry it tries to read countryList[j] rather than taking that literally while the functions made and setting it to the country name.
how do i make it set animateCountry(“united_kingdom”) inside the function being made?
anyone that can solve this is a genius ofc
many thanks for your help!