1 Reply Latest reply on Jun 1, 2008 11:42 PM by Ankur Arora

    Class question

    brian914 Level 1
      I am new to writing classes, but feel like I really need to get this down now. Been meaning to learn for some time... anyway.

      I am trying to build a class for changing the color of MCs when rolled over. For the fade, I want to use Tweener, so I want to include that in my class. I have the following:

      import caurina.transitions.*;
      import caurina.transitions.properties.ColorShortcuts;
      ColorShortcuts.init();

      class BtnColor {
      function btnRollOver(whichBtn:MovieClip, theColor:Number, duration:Number):Void {
      Tweener.addTween(whichBtn, {_color:theColor, time:duration, transition:"linear"});
      }

      }

      When I do that, I get the following errors:
      ActionScript 2.0 class scripts may only define class or interface constructs.
        • 1. Class question
          Ankur Arora Level 1
          Brian,
          A little modification in the code of Class:-

          import caurina.transitions.*;
          import caurina.transitions.properties.ColorShortcuts;
          class BtnColor
          {
          public function BtnColor()
          {
          ColorShortcuts.init();
          }
          public function btnRollOver (whichBtn:MovieClip, theColor:Number, duration:Number):Void
          {
          Tweener.addTween (whichBtn, {_color:theColor, time:duration, transition:"linear"});
          }
          }



          And in your FLA you has to include your class and call methods like:-
          var objMyClass = new BtnColor();
          objMyClass.btnRollOver(mcButton, 0x00ff00, 1);

          Please let me know if you are not able to understand my code.




          Thanks & Regards
          Ankur Arora
          Project Leader(Flash and Flex)
          http://flashdeveloper.blogspot.com
          let your thoughts fly to others... you will become rich.