5 Replies Latest reply: Jan 17, 2011 2:35 PM by kglad RSS

    Set instance name to variable on click

    BrianatArena Community Member

      Hi, I am attempting to set a movie clip's instance name to a string variable when clicked. For example: on my stage I have many mc instances named section101, section102, etc. when I click on any specific one I'd like to get the instance name (i.e. "section101") set to a string variable. So far I have:

       

       

      var sectionfocus:String = new String;

       

      addEventListener (MouseEvent.MOUSE_DOWN , setfocus );
      addEventListener (MouseEvent.MOUSE_UP , tracefocus );

       

      function setfocus (event:MouseEvent):void
      {
          sectionfocus = event.currentTarget.name;
      }

       

      function tracefocus (event:MouseEvent):void
      {
          trace( 'Section focus is on ' + sectionfocus);  

          // I would like it to return "Section focus is on section101" right now it returns "Section focus is on root1"
      }

       

      Advice would be great, thank you.