随机颜色画线

import flash.events.MouseEvent;

var darw:Boolean;
stage.addEventListener(MouseEvent.MOUSE_DOWN,down);
stage.addEventListener(MouseEvent.MOUSE_MOVE,Move);
stage.addEventListener(MouseEvent.MOUSE_UP,up);

function down(e:MouseEvent)
{
	darw = true;
	var color:int=Math.random() * 0xffffff + 0xff000000
	this.graphics.lineStyle(2,color,1);
	this.graphics.moveTo(mouseX,mouseY);
}

function up(e:MouseEvent)
{
	darw = false
}

function Move(e:MouseEvent)
{
	if (darw)
	{
		this.graphics.lineTo(mouseX,mouseY);
	}
}

package 
{
	import flash.display.MovieClip;
	import flash.geom.ColorTransform;
	import flash.events.*;
	public class Star extends MovieClip
	{
		private var starColor:uint;
		private var starRotation:Number;
		public function Star()
		{
			this.starColor = Math.random() * 0xffffff;
			var colorInfo:ColorTransform = this.transform.colorTransform;
			colorInfo.color = this.starColor;
			this.transform.colorTransform = colorInfo;
			this.alpha = Math.random();
			//Assign a random rotation speed
			//this.starRotation = Math.random() * 10 - 5;
			this.starRotation = Math.random() > 0.5 ? -1:1 * Math.random() * 5 + 5;
			this.scaleX = Math.random();
			this.scaleY = this.scaleX;
			addEventListener(Event.ENTER_FRAME,rotateStar);
		}
		private function rotateStar(e:Event):void
		{
			this.rotation +=  this.starRotation;
		}
	}
}
原文地址:https://www.cnblogs.com/602147629/p/1989959.html