1 Reply Latest reply on Apr 6, 2010 1:25 PM by Virinao

    make an object act like a string & a movieClip

    Virinao

      Hi,

      The scenario is as follows:

       

      I have a movieClip on the stage called "home_btn" and another called "home".

      When moving over the home_btn movieClip I want the timeline inside of home to play. I used the slice command to get rid of the _btn which works fine, which is proven by the trace command, but it doesn't seem to be able to enter the timeline of home.

       

       

      home_btn.addEventListener(MouseEvent.MOUSE_OVER, onOver);      


      function onOver(event:MouseEvent)

      {

              var selectedButton:Object;

              var currentTarget:String = event.target.name;

             

              selectedButton = currentTarget.slice(0, currentTarget.indexOf("_"));

              trace(selectedButton);

              selectedButton.gotoAndPlay("over");     

      }

       

       

       

      The error message I get is this:

       

      TypeError:  Error #1006: value is not a function.
           at Version1_fla::MainTimeline/onOver()

       

       


      PS: I know the obvious way to make this work, but I want it to be mass-usable. Hence the complications.

       

      Thank you for you help,

       

      Virinao

        • 1. Re: make an object act like a string & a movieClip
          Virinao Level 1

          Solved!

           

          With the help of associative Arrays. It works like a mediator between a string and the movieClips which you have on your stage!

           

           

          var tempButton:Object = new Object;
          var mySlice:String;
          tempButton["home"] = home;



          home_btn.addEventListener(MouseEvent.MOUSE_OVER, onOver);


          function onOver(event:MouseEvent)
          {
                  var currentTarget:String = event.target.name;
                  mySlice = currentTarget.slice(0, currentTarget.indexOf("_"));
                  trace(mySlice);
             
                  tempButton[mySlice].gotoAndPlay("over");       
          }