|  | Class question |  | |
| | | brian914 |  |
| Posted: Sun Jun 01, 2008 5:19 pm Post subject: Class question |  |
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. |
| |
| | | Ankur Arora |  |
| Posted: Mon Jun 02, 2008 6:42 am Post subject: Re: Class question |  |
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. |
| |
|
|