UIComponent. It must report valid measurements in order for Panel to
handle it correctly.
What you are doing is not object-oriented. Someone has probably done
it, but normally you'd create subclasses for each "kind" of widget. On
the other hand, if you know the bounds of your graphics, you can just
set the width/height of the UIComponent instance. Typical subclasses
might look like:
Class BoxGraphic extends UIComponent
{
Public var color:uint;
Override protected function commitProperties()
{
Graphics.beginFill(color)
...
}
Override protected function measure()
{
Var rect:Rectangle = getBounds();
measuredWidth = rect.width;
measuredHeight = rect.height;
}
}
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Merrill, Jason
Sent: Thursday, January 17, 2008 3:03 PM
To: [email protected]
Subject: RE: [flexcoders] Drawn objects acting as children to
components?
Thanks. So you mean a subclass of UIComplonent or Panel? And the bounds
would be relative to Panel width and height? I sort of get maybe how to
write that, I mean, I know how to subclass components and do method
overriding, but not sure how to go about doing what your suggesting
exactly. Any pointers on where to start? I tried reading in the helps
about the guts of what makes up a panel component, but couldn't finnd
what I was looking for. What makes up the panel's container area - is
that a canvas component I can reference?
This seems somewhat elementary to RIA development - surely someone has
used UIComponent.graphics draw methods to draw in a Flex app, but have
the contents be constrained inside a component container like a Panel.
Surely I'm not the first, no?
Jason Merrill
Bank of America
GT&O L&LD Solutions Design & Development
eTools & Multimedia
Bank of America Flash Platform Developer Community
________________________________
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui
Sent: Thursday, January 17, 2008 5:47 PM
To: [email protected]
Subject: RE: [flexcoders] Drawn objects acting as children to
components?
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