1 Reply Latest reply on Aug 4, 2006 2:37 PM by Newsgroup_User

    need help in setting up a loop

    MediaMan5335 Level 1
      for example:
      Having a map with several cities on it. When you roll over the city name, a movie clip appears displaying that city's info. There is going to be many cities, so we want to shorten the code using a loop..or an array, i don't know.

      I tried naming all the city buttons as 'city1_btn, city2_btn ect, and the corresponding movie clips as 'city1_mc, city2_mc ect. And I tried using the following loop to make the movie clips appear, but with no luck:

      for(i=1; i<4; i++){
      //to hide the movie clips to start (this part works)
      _root["city"+i+"_mc"]._visible=false;

      //to loop the button scripts (doesn't work)
      _root["city"+i+"_btn"].onRollOver=function(){
      _root["city"+i+"_mc"]._visible=true;
      }
      _root["city"+i+"_btn"].onRollOut=function(){
      _root["city"+i+"_mc"]._visible=false;
      }
      }
      Does anyone know how to make this loop work, or know of a better way of doing something like this I.E. using an array or something.

      Thanks,
      Mike