1 Reply Latest reply on Jun 3, 2010 6:17 AM by kglad

    Help me out to give Dynamic links using XML

    Mohan-V Level 1

      Hi All,

       

      I am new to flash. I have a Dynamic USA flash map. If i roll over on state it zoom in and roll out Zoom out. I want to give dynamic link for each state using XMl. Please help me out. Below is the code which i am using..

       

      var statesArray:Array = new Array("Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming");//array of the 50 states
      var currentLevel = 1000;//level to start putting the states on when rolled over
      var xmlObj:XML = new XML();
      xmlObj.ignoreWhite = true;
      xmlObj.load("usa-states.xml");
      easeType = mx.transitions.easing.Strong.easeOut;//type of easing used in rollover
      scalebegin = 100;//initial size of state %.
      scaleend = 150;//final size of state in pixels
      time = .9;//how long the scaling of the states takes
      scaleEndBig = 110;//for any state bigger already than scaleend use this. This is a % not pixels.
      ///////////////////////////////////////////////////////////////////////////////
      mapHit_mc._alpha = 0;//makes the map that serves as the hit area invisible

       


      for(i=0;i<50;i++){//runs one time for each state
           if(i<10){//makes 01 just 1
               stateNum = "0"+i;
           }else{
               stateNum = i;
           }
           eval("mapHit_mc.state"+stateNum+"_mc").onRelease = function(){
               thisState = this._name.substr(5,2);//gets the state number from the name
               if(thisState.substr(0,1)=="0"){//makes 01 just 1
                   thisState = thisState.substr(1,1);
                  
               }
               selectedState = statesArray[thisState];//associate the clicked state with the state names in the array
               state_txt.text = selectedState;//puts the state name in the text box
               xmlObj.onLoad = function(success) {
                  
               }
           }
           eval("mapHit_mc.state"+stateNum+"_mc").onRollOver = function(){//rollover the invisible hit area
               animateClip1 = "map_mc.state"+this._name.substr(5,2)+"_mc";//determine state to animate
               animateClip = eval(animateClip1);//make animateClip variable one that can be read in easing script
               eval(animateClip).swapDepths(currentLevel);//move state to highest level
              
               currentLevel++;
               if(getProperty(animateClip, _width)<getProperty(animateClip, _height)){//determines if its wider than it is tall
                   greaterDimension =     getProperty(animateClip, _height);
                  
               }else{
                   greaterDimension =     getProperty(animateClip, _width);  
               }
               if(greaterDimension>scalebegin){//if the state is already bigger than the desired ending size.
                   greaterDimension = scaleEndBig;
               }
               scaleEndPerc = (scaleend/greaterDimension)*100;//determines the % a state has to increase to be the desired size in pixels
               new mx.transitions.Tween(animateClip, "_xscale", easeType, getProperty(animateClip, _xscale), scaleEndPerc, time, true);//tween x
               new mx.transitions.Tween(animateClip, "_yscale", easeType, getProperty(animateClip, _yscale), scaleEndPerc, time, true);//tween y
                           var my_color:Color = new Color(animateClip1.or_mc1);
               // set the color
               trace(animateClip1;
               my_color.setRGB(0xFF0000);
               var myValue:String = my_color.getRGB().toString(16);
           }
          
           eval("mapHit_mc.state"+stateNum+"_mc").onRollOut = function(){
               animateClip1 = "map_mc.state"+this._name.substr(5,2)+"_mc";//determine state to animate
               animateClip = eval(animateClip1);//make animateClip variable one that can be read in easing script
               new mx.transitions.Tween(animateClip, "_xscale", easeType, getProperty(animateClip, _xscale), scalebegin, time, true);//tween x
               new mx.transitions.Tween(animateClip, "_yscale", easeType, getProperty(animateClip, _yscale), scalebegin, time, true);//tween y
              
              
           }
           eval("mapHit_mc.state"+stateNum+"_mc").onReleaseOutside = function(){//same as above but for release outside
               animateClip1 = "map_mc.state"+this._name.substr(5,2)+"_mc";
               animateClip = eval(animateClip1);
               new mx.transitions.Tween(animateClip, "_xscale", easeType, getProperty(animateClip, _xscale), scalebegin, time, true);
               new mx.transitions.Tween(animateClip, "_yscale", easeType, getProperty(animateClip, _yscale), scalebegin, time, true);
                   }
          
          
      }

       

      Thanks in Advance.

      monu