[AS3]as3.0在不同MC中的两点间距离
[AS3]as3.0在不同MC中的两点间距离
[AS3]as3.0在不同MC中的两点间距离
- import flash.geom.*;
- var pt1:Point = new Point(circle1.x, circle1.y);
- pt1 = circle1.localToGlobal(pt1);
- var pt2:Point = new Point(circle1.x, circle1.y);
- pt2 = circle2.localToGlobal(pt2);
- var distance:Number = Point.distance(pt1, pt2);
- //类似地,可以求两MC相对于注册点的距离:
- import flash.geom.*;
- var stageCenter:Point = new Point();
- stageCenter.x = this.stage.stageWidth / 2;
- stageCenter.y = this.stage.stageHeight / 2;
- var targetCenter:Point = new Point(target.x, target.y);
- targettargetCenter = target.localToGlobal(targetCenter);
- var distance:Number = Point.distance(stageCenter, targetCenter);
- //移动MC到一定的角度与距离:
- import flash.geom.*;
- var distance:Number = 100;
- var angle:Number = 2 * Math.PI * (90 / 360);
- var translatePoint:Point = Point.polar(distance, angle);
- myDisplayObject.x += translatePoint.x;
- myDisplayObject.y += translatePoint.y;
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...