PointDescriptor.as
2.77 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package control
{
import flash.events.MouseEvent;
import flash.geom.Point;
import mx.controls.Alert;
import mx.core.UIComponent;
import mx.collections.ArrayCollection;
public class PointDescriptor extends UIComponent
{
//定点样式
private var _thinkness:Number = 3;
private var _color:uint = 0x000000;
private var _alpha:Number = 1;
private var _pixelHinting:Boolean = false;
private var _scaleMode:String = "normal";
private var _x:int=0;
private var _y:int=0;
private var _index:int=0;
private var _line:PolylineDescriptor;
public function PointDescriptor(x:int,y:int,line:PolylineDescriptor,canEdit:Boolean)
{
_x=x;
_y=y;
_line=line;
draw();
this.doubleClickEnabled=true;
//Alert.show("test");
//addE
if(canEdit){
addEventListener(MouseEvent.MOUSE_OVER,doOver);
addEventListener(MouseEvent.MOUSE_UP,doUp);
addEventListener(MouseEvent.MOUSE_DOWN,doClick);
addEventListener(MouseEvent.DOUBLE_CLICK,doDClick);
}
//addEventListener(MouseEvent.MOUSE_DOWN,doClick);
}
private function doUp(e:MouseEvent):void{
_line.activePoint=null;
}
private function doOver(e:MouseEvent):void{
_color=0x0000ff;
draw();
}
private function stopEvent(e:MouseEvent):void{
e.stopImmediatePropagation();
}
private function doClick(e:MouseEvent):void{
//Alert.show("tset");
_line.activePoint=this;
e.stopImmediatePropagation();
e.stopPropagation();
}
private function doDClick(e:MouseEvent):void{
//Alert.show("test");
return;
var _index:int=1;
var _pionts:ArrayCollection=_line.points;
if(_pionts.length>3){
_index=index;
}
var point:Point=null;
if(_index==2&&false){
point =_line.getMiddlePoint(_pionts.getItemAt(_index-2)as Point,_pionts.getItemAt(_index+2) as Point);
}else{
point =_line.getMiddlePoint(_pionts.getItemAt(_index-1)as Point,_pionts.getItemAt(_index+1) as Point);
}
//_pionts
_pionts.setItemAt(point,_index);
if(_index==2){
_line.updateLable(point);
}
//_line.removePointAt(_index);
this.updatePoint(point.x,point.y);
//graphics.clear();
e.stopPropagation();
}
public function updatePoint(newX:int,newY:int):void{
_x=newX;
_y=newY;
draw();
}
/**
* 划点
* */
public function draw():void{
graphics.clear();
with(graphics){
//graphics.lineStyle(2,0x990033,1);
graphics.beginFill(_color); //填充颜色
//Alert.show(""+_x+"%%"+_y)
graphics.drawCircle(_x,_y,4);
graphics.endFill(); //停止填充
}
//Alert.show(this.parent.name);
//Alert.show(hasArrowHead+"");
}
public function remove():void{
graphics.clear();
}
public function set index(index:int):void{
this._index=index;
}
public function get index():int{
return this._index;
}
}
}