Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScript

Class question

 
Jump to:  
 
brian914
PostPosted: 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
PostPosted: 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.
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

Pozycjonowanie Fotka mieszkania łódź sypialnia Kwiaty