So I've been writing an Actionscript component that extends UIComponent
and is wrapped inside a Panel tag. The UIComponent has code that draws
a flowchart of sorts into the content area of the Panel, based on a
dataprovider it's bound to. Everything works fine there, and the drawn
graphics change when the dataprovider changes automatically. The drawn
objects also stay within the boundaries of the Panel content area,
thanks to some help on this list with overriding some protected methods.
The problem I still have though, is getting the drawn content to stay
centered in the content area, including when the Panel is resized
(either by resizing the browser window, since the Panel's width is 100%,
or by moving an HDividedBox divider that separates it from other
panels), or when the drawn content changes size. I can measure the size
of the drawn content easily enough using the getBounds() method of
Rectangle class, but not the Panel's content area - the width and height
seem to be way off when I measure them.
The other problem is getting the scrollbars to be accurate. I'm getting
really confused by Panel's unscaledWidth, unscaledHeight, measuredWidth,
measuredHeight, width, height, explicitWidth, and explicitHeight
properties and how they all relate to each other. Is there someone who
can explain how the panel's content area size is calculated and also the
scrollbars?
Here is some code snippets from my class:
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
reposition();
measuredWidth = unscaledWidth;
measuredHeight = unscaledHeight;
}
override protected function measure():void
{
var rect:Rectangle = getBounds(this);
measuredWidth = rect.width;
measuredHeight = rect.height;
var flowchartRect:Rectangle = getBounds(_flowchart);
_flowchartWidth = flowchartRect.width;
_flowchartHeight = flowchartRect.height;
}
private function reposition(e:Event):void
{
measure();
_flowchart.x = (width/2)-(_flowchart/2);
_flowchart.y = (height/2)-(_flowchart/2);
}
Thanks,
Jason Merrill
Bank of America
GT&O L&LD Solutions Design & Development
eTools & Multimedia
Bank of America Flash Platform Developer Community
Interested in innovative ideas in Learning?
Check out the GT&O Innovative Learning Blog
<http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/default.aspx>
and & subscribe
<http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/_layouts/SubNew.a
spx?List=%7B41BD3FC9%2DBB07%2D4763%2DB3AB%2DA6C7C99C5B8D%7D&Source=http%
3A%2F%2Fsharepoint%2Ebankofamerica%2Ecom%2Fsites%2Fddc%2Frd%2Fblog%2FLis
ts%2FPosts%2FArchive%2Easpx> .