I guess these days I would do it in a different way but still does the job; to use it, just copy and paste the following code into your actionscript editor and save it as ChangeColour.as
/*
*
* Version 1
*
* Movieclip rollOver and rollOut ChangeColour class
*
* Author: Ernesto Quezada, Overloadstudios (ernesto.quezada(a)gmail.com)
* Date: October 2006
*
* Description: Gradually changes colour and brightness to a movieclip when rolled over
* and back to its original colour when rolled out
*
*/
class ChangeColour extends MovieClip {
private var control:Number = -10;
private var addShine:Object;
private var currentState:String;
private var myColour:Color;
// -- Constructor --
private function ChangeColour() {
currentState = "rolledOut";
}
// -- Events --
private function onRollOver():Void {
currentState = "rolledOver";
this.onEnterFrame = function () {
checkState();
};
}
private function onRollOut():Void {
currentState = "rolledOut";
}
// -- private functions --
private function checkState():Void {
myColour = new Color(this);
myColour.setTransform(addShine);
if (currentState == "rolledOver") {
if (control<=100) { control += 10; addShine = {rb:control, gb:control-20, bb:control-50}; } else { addShine = {rb:0, gb:0, bb:0}; } myColour.setTransform(addShine); updateAfterEvent(); } else if (currentState == "rolledOut") { if (control>=10) {
control -= 10;
addShine = {rb:control, gb:control, bb:control};
} else {
delete this.onEnterFrame;
}
myColour.setTransform(addShine);
updateAfterEvent();
}
}
}
Then put it in a folder called Classes (or wherever your classpath points to) and whenever you want to use it, in the Flash library, right click on a movieclip, select export for actionscript and write ChangeColour as the AS 2.0 class.
I know, I made it 9 months ago and needs a review...
salut!
2 comments:
Very usefull script. thx, However, I kkep getting a message saying: Class not compatable with As2" when I try and fill in the linkage class name in the symbols library.
Hi winston8r, are you publishing for flash player 8? or which player?
I will upload an example tomorrow :)
cheers
Post a Comment