ActionScript标记点位置的工具类

package
{
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
 
	public class MarkPoint extends Sprite
	{
		private var _parent:DisplayObjectContainer;
 
		public function MarkPoint(parent:DisplayObjectContainer,o:Object,color:uint = 0x000000,radius:uint = 2)
		{
 
			_parent = parent;
 
			this.x = o.x;
 
			this.y = o.y;
 
			graphics.beginFill(color);
 
			graphics.drawCircle(0,0,radius);
 
			graphics.endFill();
 
			var pointXY:TextField = new TextField();
 
			pointXY.text = "("+o.x+","+o.y+")";
 
			pointXY.autoSize = TextFieldAutoSize.CENTER;
 
			pointXY.textColor = color;
 
			pointXY.x = - pointXY.width/2;
 
			pointXY.y = radius;
 
			pointXY.selectable = false;
 
			addChild(pointXY);
 
			addEventListener(Event.ENTER_FRAME,enterFrameHandler);
 
			_parent.addChild(this);
 
		}
 
		//将所有的点标记移至最上层
 
		private function enterFrameHandler(event:Event):void{
 
			_parent.setChildIndex(this,_parent.numChildren-1);
 
		}
 
	}
}

Tags:

发表评论

电子邮件地址不会被公开。 必填项已用*标注