6 Replies Latest reply on Aug 23, 2007 2:47 PM by kglad

    Getting a button to change a variable in AS 3.0?

    Phalconheart
      I used to be able to do this in AS 2.0 but 3.0 has got me stumped. Here's what's not working:

      first I set a variable in my main timeline:

      =====================
      var carpetChoice:Number = 1;
      =====================

      then I set up an eventListener for the nested MC to goToAndStop at the frame set by the variable:

      =====================
      this.mc_420.mc_420Carpet.addEventListener(Event.ENTER_FRAME, carpet420);

      function carpet420(movieclip:Event):void {
      this.mc_420.mc_420Carpet.gotoAndStop(carpetChoice);
      }
      =====================

      So far so good. I've tested to make sure it worked so far by changing the original declared variable and the nested MC DID go to the appropriate frame.

      Now the problem! I try to set up an eventListener a button to change that variable (thus controlling the nested MC) but I'm making a mistake cause IT DON'T WORK!!

      =====================

      this.mc_swatchTab.mc_swatchScrollMenu.btn_swatchCarpet002.addEventListener(MouseEvent.CLIC K, carpetVar002);

      function carpetVar002(event:MouseEvent):void {
      root.carpetChoice:Number = 2;
      }
      =====================

      How can I make this work in AS 3.0?
      thanks,
      Pat