Posts Tagged “EdgeMetrics”

For some odd reason you might want to get the width and height of the inside of a Container. You can use the "viewMetrics" property of a container to do it.

			/*-------------------------------------------------------------------
			   Returns a Rectangle object of the inside view area of a Container,
			   instead of the complete width and height.
			 ---------------------------------------------------------------------*/
			private function getViewRectangle(ui:Container):Rectangle
			{
				var e:EdgeMetrics=ui.viewMetrics;
				var r:Rectangle=new Rectangle();
				r.width=ui.width - (e.left + e.right);
				r.height=ui.height - (e.top + e.bottom);
				r.x=e.left;
				r.y=e.top;
				return r;
			}

In the following example I overlay a green box over a Panel to show how it matches the Panel's size.
Comments are welcome.
Read the rest of this entry »

Vote in HexoSearch

Comments No Comments »

Thanks for visiting www.keith-hair.net