快速业务通道

初识AS3:两点间距离

作者 佚名技术 来源 服务器技术 浏览 发布时间 2012-07-07

[效果] [代码] //画两小圆
varyuan1:Sprite=newSprite();
yuan1.graphics.beginFill(0x000000);
yuan1.graphics.drawCircle(0,0,5);
addChild(yuan1);
yuan1.x=100;
yuan1.y=100;
varyuan2:Sprite=newSprite();
yuan2.graphics.beginFill(0x000000);
yuan2.graphics.drawCircle(0,0,5);
addChild(yuan2);
yuan2.x=130;
yuan2.y=140;
//显赫距离的动态文本
var_txt:TextField=newTextField();
_txt.autoSize=TextFieldAutoSize.LEFT;
addChild(_txt);
//定义直线精灵
varzhixian:Sprite=newSprite();
addChild(zhixian);
//圆1拖动和停止拖动
yuan1.buttonMode=true;
yuan1.addEventListener(MouseEvent.MOUSE_DOWN,yuan1ax);
functionyuan1ax(event:MouseEvent):void{
yuan1.startDrag();
}
yuan1.addEventListener(MouseEvent.MOUSE_MOVE,yuan1yd);
functionyuan1yd(event:MouseEvent):void{
event:gx;
}
yuan1.addEventListener(MouseEvent.MOUSE_UP,yuan1sk);
functionyuan1sk(event:MouseEvent):void{
yuan1.stopDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP,yuan1yc);
functionyuan1yc(event:MouseEvent):void{
yuan1.stopDrag();
}
//圆2拖动和停止拖动
yuan2.buttonMode=true;
yuan2.addEventListener(MouseEvent.MOUSE_DOWN,yuan2ax);
functionyuan2ax(event:MouseEvent):void{
yuan2.startDrag();
}
yuan2.addEventListener(MouseEvent.MOUSE_MOVE,yuan2yd);
functionyuan2yd(event:MouseEvent):void{
event:gx;
}
yuan2.addEventListener(MouseEvent.MOUSE_UP,yuan2sk);
functionyuan2sk(event:MouseEvent):void{
yuan2.stopDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP,yuan2yc);
functionyuan2yc(event:MouseEvent):void{
yuan2.stopDrag();
}
//更新
stage.addEventListener(Event.ENTER_FRAME,gx);
functiongx(event:Event):void{
zhixian.graphics.clear();
varzuobiao1oint=newPoint(yuan1.x,yuan1.y);
varzuobiao2oint=newPoint(yuan2.x,yuan2.y);
varjuli:Number=Point.distance(zuobiao1,zuobiao2);
zhixian.graphics.lineStyle(2,0xFF0000,1);
zhixian.graphics.moveTo(yuan1.x,yuan1.y);
zhixian.graphics.lineTo(yuan2.x,yuan2.y);
_txt.text="两点间距离:"+uint(juli*10)/10;
} 关键词:间距

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号