Skip navigation
badu
Currently Being Moderated

drawn content outside of container?

Aug 2, 2006 4:01 PM

Hi

I am having trouble when adding dynamic graphics content to a container in getting the container to scroll/recognise this content as a child.

So in a nutshell, I have some AS adding graphics/lineTo content to a sprite class and then adding that as a child to a UIComponent, then adding to a mxml declared container (tried variations Panel, HBox, Canvas etc). The lines are being drawn however as the drawn conent is larger than the visible container are I would have thought the scrollbars for the target container would kick in as the UIComponent is a child of the container.

Anyone from Adobe have a comment?

Sample:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private var UICLine:UIComponent = new UIComponent();
private var lineSprite:Sprite = new Sprite();
//
private function initApp():void{
lineSprite.graphics.lineStyle(2,0xFF0000,100);
lineSprite.graphics.moveTo(100,100);
lineSprite.graphics.lineTo(100,800);
UICLine.addChild(lineSprite);
// target container, currently a HBox
con.addChild(UICLine);
}
]]>
</mx:Script>
<mx:Panel width="100%" height="100%">
<mx:HBox width="100%" height="50%" id="con" backgroundColor="#FFFF99">
</mx:HBox>
<mx:Canvas width="100%" height="50%">
</mx:Canvas>
</mx:Panel>
</mx:Application>


Thanks
Wayne
 
Replies
  • Currently Being Moderated
    Aug 4, 2006 12:53 PM   in reply to badu
    You need to set the size UICLine. At the moment it has no size. You can draw on it, but that does not affect its size. As you can see you can easily draw outside of the container.

    Try this: UICLine.setActualSize(800,800) - large enough to contain the drawing. Now the HBox will grow large enough to show the entire line. If you want scrollbars, either use a Canvas or set a specific size on the HBox.
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points