3 Replies Latest reply on Dec 19, 2007 8:18 AM by Thomas Friedl

    updateDisplayList strange behaviour

    Thomas Friedl Level 1
      I'm working on come kind of calender which puts my "Day" objects into a HBox. These Day objects are extending UIComponent and in my updateDisplayList I just do this:

      quote:


      override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
      {
      super.updateDisplayList(unscaledWidth, unscaledHeight);

      this.graphics.lineStyle(borderWidth, 0xffffff);
      this.graphics.drawRect(x, y, width, height);
      }



      Now my problem is that only every second Day in my HBox is drawn. All other second day objects are not drawn at all (but they are there because they use the space).

      The code looks something like that:

      quote:


      for(var i:int = 0; i < 30; i++)
      {
      var day:Day = new Day(someDate);
      myHBox.addChild(day);
      }

      Here is a screenshot: http://a.imagehost.org/0087/updatedisplaylist.jpg

        • 1. updateDisplayList strange behaviour
          Thomas Friedl Level 1
          A little example to reproduce it:

          test.mxml
          quote:


          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
          creationComplete="onCreationComplete();">
          <mx:Script>
          <![CDATA[
          private function onCreationComplete():void
          {
          for(var i:int = 0; i < 10; i++)
          {
          var box:Box = new Box();
          hbox.addChild(box);
          }
          }
          ]]>
          </mx:Script>
          <mx:HBox left="0" right="0" top="0" id="hbox">
          </mx:HBox>

          </mx:Application>




          and Box.as
          quote:


          package
          {
          import flash.display.Graphics;
          import mx.core.UIComponent;

          public class Box extends UIComponent
          {
          //--------------------------------------------------------------
          public function Box():void
          {
          this.width = 50
          this.height = 50;
          }


          //--------------------------------------------------------------
          override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
          {
          super.updateDisplayList(unscaledWidth, unscaledHeight);

          this.graphics.clear();

          this.graphics.lineStyle(1, 0xff0000);
          this.graphics.drawRect(x, y, unscaledWidth, unscaledHeight);
          }
          }
          }

          • 2. Re: updateDisplayList strange behaviour
            Thomas Friedl Level 1
            Ok seems like that all my objects are drawn. Hower my objects are bigger than the the border drawn in the updateDisplayList. But why?
            • 3. Re: updateDisplayList strange behaviour
              Thomas Friedl Level 1
              haha...ok, now I feel really dumb. I used x and y instead of 0 for my drawing coordinates.

              solved.