Core tips: Flash CS4 text color easing effect tutorial.
Code Detailed:
[SWF (backgroundcolor=0x000000,width=550,height=400)]//set scene background color, size
var r:uint=0,g:uint=0,b:uint=0;//declares unsigned integer variables r, g, B, and the initial value is 0
var color:uint,targetr:uint,targetg:uint,targetb:uint;//declares unsigned integer variables color, targetr, TARGETG, TARGETB
var filtersco:uint,filtersr:uint,filtersg:uint,filtersb:uint;//declares unsigned integer variables Filtersco, FILTERSR, FiltersG, FiltersB
Var glowf:glowfilter;//declares a light-emitting filter class instance GLOWF
var matrix:matrix=new matrix ()//declaration of a matrices class instance matrix
Matrix.creategradientbox (550,200,0,0,0)//Set vector graph gradient fill required matrix style (width 550, height 200, rotation 0,x direction translation 0,y Direction translation 0)
var sh:shape=new Shape ()//Declare a vector diagram class instance sh
Sh.graphics.beginGradientFill (GRADIENTTYPE.LINEAR,[0XFF0000,0XFFFF00,0X00FF00,0X00FFFF,0X0000FF,0XFF00FF, 0xff0000],[1,1,1,1,1,1,1],[0,42,84,126,168,210,255],matrix)//Set gradient fill style (linear gradient, color block color, transparency, color block position, matrix)
Sh.graphics.drawRect (0,0,550,200)//Draw rectangle in sh (upper left corner coordinate (0,0), width 550, height 200)
Sh.graphics.endFill ()//End Fill
var bmd:bitmapdata=new BitmapData (550,200)//Declare a bitmap data class instance BMD (width 550, height 200)
var bim:bitmap=new Bitmap (BMD);//Declare a bitmap wrapper class instance BIM, for packing BMD
Bmd.draw (SH);//bitmap BMD for vector image sh photo
AddChild (BIM)//Add bitmap BIM to display list
var txt:textfield=new TextField ()//Declare a text class instance txt
AddChild (TXT);//Add text TXT to display list
Txt.defaulttextformat=new TextFormat ("Chinese amber", 60);//Set text formatting (font, size) Note This setting does not work until it is placed in front of the content
Txt.text= "multi-special software station welcome you!" ";//text content
txt.autosize=textfieldautosize.center;//Text txt auto resize and center align
txt.x=stage.stagewidth/2-txt.width/2;//the x-coordinate of the text, placing the text in the middle of the stage
txt.y=stage.stageheight*3/4-txt.height/2;//the y-coordinate of the text, place the text in portrait 3/4
AddEventListener (event.enter_frame,frame);//Add frame-frequency event listening, calling function frame
function Frame (e) {//define Frame frequency event function frame
Color=bmd.getpixel (Mousex,mousey);//color gets the color of the pixel at the bitmap mouse
Targetr=color>>16;//targetr gets the value of the red channel in color
TARGETG=COLOR>>8&0XFF;//TARGETG gets the green channel value in color
Targetb=color&0xff;//targetb gets the value of the blue channel in color
R+=uint ((targetr-r) *0.03)//r per frame increased by 0.03 times times the difference between TARGETR and R
G+=uint ((targetg-g) *0.03)//g per frame increased by 0.03 times times the difference between TARGETG and G
B+=uint ((targetb-b) *0.03)//b per frame increases by 0.03 times times the difference between TARGETB and B
txt.textcolor=r<<16g<<8b;//the R, G, b synthetic color value to text txt
FILTERSR=0XFF-R;//FILTERSR gets the difference between 0xFF and R
FILTERSG=0XFF-G;//FILTERSG gets the difference between 0xFF and G
FILTERSB=0XFF-B;//FILTERSB gets the difference between 0xFF and B
filtersco=filtersr<<16filtersg<<8filtersb;//FILTERSR, FILTERSG, FILTERSB synthetic color to the value of FiltersCo
Glowf=new Glowfilter (filtersco,1,8,8)//Glow filter GLOWF instantiation (color, transparency, X-direction blur, Y-direction blur value)
txt.filters=[glowf];//text Apply a glow filter
}
============ description
var txt1:textfield=new TextField ()//Declare a text class instance txt
Addchildat (txt1,numchildren-1)//Add txt to the bottom of the display list
Txt1.defaulttextformat=new TextFormat ("XXFarEastFont-Arial", 20,0x00cc33); Set text format for TXT (Arial, 30th, dark green)
txt1.text= "Full script text color easing effect mouse sliding color map change text colors";/txt text content
txt1.x=20;//text txt x coordinates get 20
txt1.y=360;//text txt's y-coordinate gets 360
txt1.width=550;//text txt width get 220
Txt1.filters=[new Dropshadowfilter (2,45,0x0)];//Add a projection filter for text (distance 5, direction 45 degrees, color black)