3 Replies Latest reply: Feb 18, 2013 2:18 AM by moccamaximum RSS

    assign bitmap movieClip

    jagguy999 Community Member

      Hi,

       

      I have a movieClip and I want to click a button and change the movieClip image, how do I do this?

       

       

      mc1.addEventListener(MouseEvent.CLICK, mymc1ClickHandler);

       

      function mymc1ClickHandler(evtObj:MouseEvent){

      trace("Change movie Clip here");

       

      }

        • 1. Re: assign bitmap movieClip
          moccamaximum Community Member

          The easiest way tod do this: put two pictures on keyframes with a stop() command inside your movieclip and toogle the display like this:

           

          function mymc1ClickHandler(evtObj:MouseEvent){

                   // the modulo Operator [%] will take care that 1switches to 2 and 2 switches to 1

                    evtObj.currentTarget.gotoAndStop((evtObj.currentTarget.currentFrame%2)+1);

           

          }

          • 2. Re: assign bitmap movieClip
            jagguy999 Community Member

            Hi,

             

            That works u what about roll over/rollout functions?

            I wan to switch image wi th these 2 events? do I place all the code in the MovieClip timeline?

            • 3. Re: assign bitmap movieClip
              moccamaximum Community Member

              you should place all the code on frame 1 of your main (highest) timeline.

              If your buttons are embeded in other MovieClips you can use

               

              //if your movieClip is called "container"

              container.mc1.addEventListener(MouseEvent.CLICK, mymc1ClickHandler);

              container.mc1.addEventListener(MouseEvent.ROLL_OVER, mymc1_overHandler);

              container.mc1.addEventListener(MouseEvent.ROLL_OUT, mymc1_outHandler);