0
我會對我怎樣才能使一個線的問題,以捕捉到物體的中心,在我來說,我得出了一些圓圈時按下按鈕,然後另一個按鈕添加行,但我想它們捕捉到中心,因此,當我移動至圓的線延伸/壓縮其中i創建圓的代碼:AS3快線對象
function new_sond(event:MouseEvent):void
{
if (i<9)
{
i++;
q=i;
var btn:Sprite = new Sprite();
btn.graphics.beginFill(0x0099FF, 1);
btn.graphics.drawCircle(400, 300, 15);
btn.graphics.endFill();
var s:String = String(q);
btn.name=s;
var textField = new TextField();
textField.mouseEnabled=false;
textField.text = i;
textField.width = 10;
textField.height = 17;
textField.x = 395; // center it horizontally
textField.y = 292; // center it vertically
btn.addChild(textField);
this.addChild(btn);
}}
其中i畫線從圓中的代碼來圈
function click1(e:MouseEvent):void{
e.currentTarget.removeEventListener(MouseEvent.CLICK, click1);
if (e.target.name!=null){
cntr=cntr+1;
trs=e.target.name;
var trn = Number(trs);
du[cntr]=trn;
sx=e.target.x+400;
sy=e.target.y+300;
stage.addEventListener(MouseEvent.CLICK,click2);
}
}
function click2(e:MouseEvent):void{
e.currentTarget.removeEventListener(MouseEvent.CLICK, click2);
fx=e.target.x+400;
fy=e.target.y+300;
var i:int;
i=2;
trs=e.target.name;
var trn = Number(trs);
u[cntr]=trn;
var line:Shape = new Shape();
line.graphics.lineStyle(1,0xFF0000,2);
line.graphics.moveTo(sx,sy);
line.graphics.lineTo(fx,fy);
this.addChild(line);
var inputField:TextField = new TextField();
inputField.border = true;
inputField.type = TextFieldType.INPUT;
inputField.width = 23;
inputField.height = 18;
inputField.x = (sx+fx)/2;
inputField.y = (sy+fy)/2;
inputField.multiline = false;
inputField.maxChars = 3;
inputField.restrict = "0-9";
inputField.addEventListener(Event.CHANGE, checkInput);
addChild(inputField);
}
很抱歉的長期職位,但我真的需要一些幫助,我只是不t know how to do it and have no ideas, it is a big project i
米正在爲模擬MaxFlow 它的外觀:http://gyazo.com/d0478d967b4cc34b59490245b3530e26 我只是想知道是否有可能使線捕捉到的圈子的中心......