霓虹灯的制作
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.ColorTransform;
public class SampleColor extends Sprite
{
public function SampleColor()
{
for (var i:int=0; i < 50; i++)
{
initSp();
}
}
private function initSp():void
{
var sp = new Sprite ;
sp.graphics.beginFill(0x0000ff);
sp.graphics.drawCircle(0,0,5);
sp.graphics.endFill();
addChild(sp);
sp.x = 200;
sp.y = 200;
sp.addEventListener(Event.ENTER_FRAME,trans);
function trans(evt:Event):void
{
var trans:ColorTransform = new ColorTransform ;
trans.color = RandRGB();
sp.transform.colorTransform = trans;
sp.x = Math.random() * 800;
sp.y = Math.random() * 400;
}
}
private function RandRGB():uint
{
return (Math.random() * 0xffffff + 0x000000);
}
}
}