`
shake863
  • 浏览: 638588 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

获取flash显示区域 的 getBounds 和 getRect

    博客分类:
  • AS
阅读更多

getBounds(targetCoordinateSpace:DisplayObject):Rectangle
返回一个矩形,该矩形定义相对于 targetCoordinateSpace 对象坐标系的显示对象区域。

getRect(targetCoordinateSpace:DisplayObject):Rectangle
返回一个矩形,该矩形根据 targetCoordinateSpace 参数定义的坐标系定义显示对象的边界,但不包括形状上的任何笔触。

 

 

package 
{
	import flash.display.*;
	import flash.events.Event;
	
	/**
	 * getBounds 获取显示区域矩阵
	 */
	public class Main extends Sprite 
	{
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			// container 
			var container:Sprite = new Sprite();
			container.x = 100;
			container.y = 100;
			this.addChild(container);
			
			// contents
			var contents:Shape = new Shape();
			contents.graphics.lineStyle(1, 0x303030);
			contents.graphics.drawCircle(0, 0, 99.5);
			container.addChild(contents);
			
			trace(contents.width, contents.height);
			// 200 200
			
			trace(container.width, container.height);
			// 200 200
			
			trace(container.x, container.y)
			// 100 100
			
			trace(contents.x, contents.y);
			// 0 0
			
			trace(contents.getBounds(container));
			  // (x=-100, y=-100, w=200, h=200)
			trace(contents.getBounds(this));
			  // (x=0, y=0, w=200, h=200)
			trace(contents.getBounds(contents));
			  // (x=-100, y=-100, w=200, h=200)
			
		}
		
	}
	
}
分享到:
评论

相关推荐

    flash action script 经典字典教程大全,学flash必备

    flash action script 经典字典教程大全,学flash必备 -- --(递减) ++ ++(递增) ! !(逻辑 NOT) != !=(不等于) !== !==(不全等) % %(模) %= %=(模赋值) & &(按位 AND 运算符) && ...

    as2.0amlabfire.zip_BitmapData_True Blue

    var clipBounds: Object = blueSpotClip.getBounds() var blueSpot: BitmapData = new BitmapData( clipBounds.xMax, clipBounds.yMax, true, 0 ) blueSpot.draw( blueSpotClip, new Matrix() ) blueSpotClip....

    leaflet-areaselect:用于让用户使用矩形选择地图区域并获得边界框的小叶插件

    传单区域选择 AreaSelect是一个传单插件,可让用户使用地图顶部可调整大小的居中框来选择正方形区域(边框)。 另一个类似的插件是 ,它解决了相同的问题,但提供了一个可移动且不固定在中心的矩形,但不支持保持宽...

    city-boundaries-google-maps:在Google地图上绘制城市边界(界限)

    查找城市边界并将其显示在Google Maps画布上的主要JavaScript文件。 使用输入的城市创建图例。 Utility-functions.js 一些小的实用程序。 依序关系 该JavaScript获取指定的边界关系并构造路径数组。 这些路径由...

    百度地图使用的demo

    ##要想显示地图,必须设定中心坐标和放大级别(范围为3-18级) var point=new BMap.Point(113.63156,34.83794); map.centerAndZoom(point, 15); ##添加版权 var cr = new BMap.CopyrightControl({anchor: BMAP_ANCHOR...

    xrope:原生 as3 显示对象的简单布局库

    AtomLayout 使用getBounds()对齐 DisplayObject。 不用担心FLA 中的注册点。 (将useBounds设置为true ,默认为false ) 轻松合成布局元素/组。 不再需要 DisplayObjectContainer。 如何使用 创建一个实现...

    sodaWithinBox:使用传单的 getBounds() 方法进行 inside_box 查询的简单 SODA API 示例

    使用 Leaflet 的 SODA inside_box() 示例一个简单的网络地图,它从传单中获取当前边界框并从 SODA API 中提取数据,在地图上创建带有弹出窗口的标记。该地图在固定位置加载并检索过去 7 天来自纽约市的 311 次投诉以...

    svg-path-bounds:获取svg路径数据的边界框

    const getBounds = require ( 'svg-path-bounds' ) let [ left , top , right , bottom ] = getBounds ( 'M0 0L10 10 20 0Z' ) // [0, 0, 20, 10] bounds = getBounds(path | segments) 计算字符串或数组的边界...

    node-window-manager:使用Node.js管理Windows,macOS和Linux中的窗口

    下面的示例显示如何获取当前焦点窗口的标题并将其隐藏。 const { windowManager } = require ( "node-window-manager" ) ; const window = windowManager . getActiveWindow ( ) ; // Prints the currently focused...

    D3-Integration:收集所有精美的D3 SVG代码

    D3出色的SVG集成 该存储库主要专注于绘制/收集交互式,清晰,易于使用的数据...交互式显示标签 根据数据填充颜色 向折线图添加阴影 添加对应于不同轴的多线 添加与输入数据相对应的渐变CSS效果 具有拖动事件的Sankey图

    java多种改变字体样式实例

    j < shape.getBounds().y + shape.getBounds().height; j=j+3) { Line2D line = new Line2D.Float( 0.0f, (float) j, (float) w, (float) j); g2.draw(line); } } public static void main(String s[]) { ...

    作者:金哲显编的软件

    // 获取显示器的桌面区域。 this.TransparencyKey = this.BackColor; // 窗体背景透明化。 NotifyIcon notify = new NotifyIcon(); notify.Visible = true; // 图标在任务栏的通知区域中可见。 notify.Icon = ...

    ClipImageClipImageClipImageClipImageClipImageClipImage

    this.Bounds = Screen.GetBounds(this); // 获取屏幕的边界。 this.TransparencyKey = this.BackColor; // 窗体背景透明化。 notifyInfo = new NotifyIcon(); notifyInfo.Visible = true; // 图标在任务栏的通知...

    华容道 小游戏 源代码

    Rectangle directionRect=direction.getBounds(); for(int k=0;k;k++) { Rectangle personRect=person[k].getBounds(); if((manRect.intersects(personRect))&&(man.number!=k)) { move=false; } } if...

    汉诺塔java代码注释

    int x=this.getBounds().x+this.getBounds().width; int y=this.getBounds().y; tower.getAutoMoveDisc().setLocation(x,y); tower.getAutoMoveDisc().setSize(280,this.getBounds().height); tower....

    C#100例题 献给c#初学者

    this.SetBounds(this.Left, this.Top, Rows[0].GetBounds().Width, this.Height); TheScore = new Score(ClientRectangle.Right - 50, ClientRectangle.Bottom - 180); // choose Level SpeedDialog dlg = ...

    bound-points:查找一组点的边界框

    var getBounds = require ( 'bound-points' ) var points = [ [ - 1 , 1 ] , [ 5 , 10 ] , [ - 8 , 13 ] ] console . log ( '2d:' , getBounds ( points ) ) var mesh = require ( 'bunny' ) console . log ( '3d:' ...

    仿QQ登录窗体,拉伸展开!

    // 显示窗体的登录进度面板 getGlassPane().setVisible(true); } }*/ public static void main(String[] args) { try { UIManager .setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel")...

    [ASP.NET.AJAX编程参考手册(涵盖ASP.NET.3.5及2.0)].(美)霍斯拉维.扫描版.pdf

    6.1.8 getBounds 6.2 MouseButton 6.3 Key 6.4 委托 6.4.1 Namespace 6.4.2 Mover 6.4.3 TextProvider 6.4.4 ImageProvider 6.5 DomEvent 6.5.1 构造函数 6.5.2 静态方法 6.5.3 实例方法 6.6 使用DomEvent类 6.6.1 ...

    华容道基于Java swing开发

    Rectangle dirctionRect = direction.getBounds(); for (int k = 0; k ; k++) { Rectangle personRect = person[k].getBounds(); if ((manRect.intersects(personRect)) && (man.number != k)) move = ...

Global site tag (gtag.js) - Google Analytics