6 Replies Latest reply on Jan 22, 2010 1:58 PM by rgadiparthi

    problem with hbox

    venkateshk Level 1

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
           creationComplete="cc()">
          <mx:Script>
              <![CDATA[
                  import mx.containers.Box;
                  private var box:Box;
                  private function cc():void{
                       for(var i:int=0;i<hb1.width;i=i+15)
                      {
                          box = new Box();
                          box.width=15;
                          box.height = hb1.height-2;
                          box.setStyle("borderStyle","solid");
                          hb1.addChild(box);
                      }
                  }
                 
                  //can1.getchi
              ]]>
          </mx:Script>
         
          <mx:HBox id="hb1" width="100" height="50" x="40" y="40" backgroundColor="#999999"
              minHeight="0" minWidth="0" borderStyle="solid" horizontalGap="0"
              paddingLeft="0" paddingRight="0" paddingTop="0" paddingBottom="0"/>
      </mx:Application>
      it's not filluping the hbox with boxes correctly

      I want the boxes to be fit in the hbox

      please............. help me

        • 1. Re: problem with hbox
          Sebastien V. Level 3

          What's the result and what do you expect it to be?

          • 2. Re: problem with hbox
            venkateshk Level 1

            The result is fill up the boxes but they are not fit in the hbox

            I want a hbox in that i want to fill boxes with 15 width each side by side

            • 3. Re: problem with hbox
              Sebastien V. Level 3

              I think I see what you're trying to do, but I still can't understand what the problem is.

              What do you mean exactly by 'the boxes are not fit in the hbox" ?

              Are there margin on the left, right, top or bottom? Are the boxes completely outside of your HBox? Are there margin between the boxes?

              • 4. Re: problem with hbox
                NFRIACowboy Level 1

                Well, as we use to say "Keep it Simple"

                 

                instead of doing calculations on the for cycle that is not good for performance do it before see my example:

                 

                private function cc():void{

                            var count:int = Math.floor(hb1.width / 15);

                                 for(var i:int=0;i<count;i++)

                                {

                                    box = new Box();

                                    box.width=15;

                                    box.height = hb1.height-2;

                                    box.setStyle("borderStyle","solid");

                                    hb1.addChild(box);

                                }

                            }

                 

                I guess that is easy to understand where the problem was

                • 5. Re: problem with hbox
                  venkateshk Level 1

                  it's not coming with ur suggestion but when i remove borderStyle property of HBox it's working fine

                  but i don't understand what's going on here

                  • 6. Re: problem with hbox
                    rgadiparthi Level 2

                    use canvas instead of Hbox, it will work.

                     

                    or add canvas inside u r Hbox.