-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFlashyText.as
More file actions
46 lines (43 loc) · 1.21 KB
/
FlashyText.as
File metadata and controls
46 lines (43 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package {
import flash.display.MovieClip;
import flash.events.*;
import fl.motion.Color;
import flash.geom.ColorTransform;
public class FlashyText extends MovieClip{
private var _root:*;
private var ran:Boolean;
private var count:int;
private var txtColor:int;
private var dynamicColor:Color = new Color();
public function FlashyText(passMsg:String, whichColor:int) {
addEventListener(Event.ADDED,beginClass);
addEventListener(Event.ENTER_FRAME, eFrame);
addEventListener(Event.REMOVED_FROM_STAGE, destroyThis);
if (whichColor == 1){
this.redText.text = passMsg;
} else if (whichColor == 2){
this.greenText.text = passMsg;
}
}
private function beginClass(e:Event):void {
if (!ran){
ran = true;
_root = MovieClip(root);//setting the root
dynamicColor.alphaMultiplier = 1.0;
}
}
private function eFrame(e:Event):void{
if (count >= 96){
dynamicColor.alphaMultiplier *= .9;
this.transform.colorTransform = dynamicColor;
}
if (count >= 160){
destroyThis();
}
count++;
}
private function destroyThis(event:Event = null):void{
this.removeEventListener(Event.ENTER_FRAME, eFrame);
}
}
}