UIComponent does not map its width/height to the bounds of what you
draw.  Therefore the Panel doesn't know that it has size and doesn't
correctly know when to clip it or how to layout according to its size.
You could write a subclass that does map width/height to those bounds.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Merrill, Jason
Sent: Thursday, January 17, 2008 12:27 PM
To: [email protected]
Subject: [flexcoders] Drawn objects acting as children to components?

 


Subject sums it up, but to clarify, I'm using the draw API in AS#
(Sprite.graphics methods) to draw dynamically draw objects in sprites
inside a panel holding a UIComponent:

i.e. networkBrowser.graphics.drawCircle(100, 100, 50);

and then in MXML:

<mx:Panel id="networkBrowserPanel" width="100%" height="100%"
layout="absolute" title="Network" >
<mx:VBox horizontalAlign="left">
<mx:UIComponent id="networkBrowser" />
</mx:VBox>
</mx:Panel>

it works great. However, since the panel's width is intentionally 100%
and height 100% so that when the browser window is resized, the panel
resizes accordingly, the problem I have found with using the draw
methods is that the objects that are drawn don't act like children of
the Panel or Vbox components. For example, when you resize the browser
and the panel re-sizes, the drawn graphics do not move- in fact, if you
resize the panel enough, the graphics can appear OUTSIDE the panel.
Also, naturally I would like the graphics to be masked by the panel's
canvas, so that if the graphics are scaled up, they don't appear outside
the Panel, and if there is a lot of graphics drawn which extend outside
of the Panel's canvas, scrollbars will automatically appear. 

I can post an image if that helps to show the problem. Thanks for any
help, I'm sure this has been covered before, but I couldn't locate it in
the archives.

Jason Merrill
Bank of America 
GT&O L&LD Solutions Design & Development 
eTools & Multimedia 

Bank of America Flash Platform Developer Community

 

Reply via email to