0 Replies Latest reply on Nov 4, 2010 7:41 AM by SiHoop

    Container problem

    SiHoop Level 1

      I'm trying to make a Sprite fit into a container, but the graphics drawn in the Sprite appear to override the bounds of the container. The class ColorBlock.as has graphics drawn in it, and the idea is that those graphics will expand as content that will be placed into the class increases. When the width of the class becomes larger than the container into which it is placed (i.e. the HBox), I want the HBoxto become scrollable. In this way, the user would have to scroll to access content that is too big to fit in the HBox. How do I prevent the grahics from 'spilling out' of the HBox?

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  creationComplete="init()">
          <mx:Script>
              <![CDATA[
                  private var chart:ColorBlock;
                  private function init():void{
                      chart=new ColorBlock();
                      comp.addChild(chart)
                  }
              ]]>
          </mx:Script>
          <mx:HBox width="500" height="500"   backgroundColor="0xffff00">
              <mx:UIComponent id="comp" />
          </mx:HBox>
      </mx:Application>

       

      ColorBlock.as

       

      package{
          import flash.display.Sprite;
          public class ColorBlock extends Sprite{
              private var _chart:Sprite;
              public function ColorBlock(){
                  super();
                  _chart = new Sprite();                       
                  addChild(_chart);
                  _chart.graphics.beginFill(0xff0000,1)
                  _chart.graphics.drawRect(0, 0, 800, 500);
              }
          }
      }