0 Replies Latest reply on Nov 7, 2006 11:39 AM by fly42

    resizing canvas not working?

    fly42
      Hello all,

      I'm a absolute beginner at flex and I have a slight problem with resizing a control derrived of Canvas (which is the child of another canvas).

      Setting the height property does not seem to change its internal height.

      For example, if I have a canvas with height 400 and set the height to 10, an click event handler will still fire if I click in the region of the original canvas (with height 400). I would expect the clickable region to change according to the new height.

      Also, if I draw the background of an canvas within updateDisplayList with drawRoundRect, and reset the height, I would expect the background (ie the canvas parent) to show/invalidate the part that was previously occluded by the bigger canvas. This does not happen, not even when I try to force an invalidation using invalidateSize and/or invalidateDisplayList.

      What am I missing?

      Thanks!
      Ben


      Included the code for a sample canvas:

      package code
      {
      import mx.containers.Canvas;
      import mx.events.*;
      import flash.events.MouseEvent;
      import mx.effects.*;
      public class TestCanvasClass extends Canvas
      {
      public function TestCanvasClass() {
      this.addEventListener(MouseEvent.CLICK, OnClick);
      }
      private function OnClick(e :MouseEvent) :void {
      SlideIn();
      }

      public function SlideIn() :void {
      this.height = 10;
      }

      override protected function updateDisplayList(w:Number, h:Number):void {
      super.updateDisplayList(w, h);
      DrawBackground();
      }
      private function DrawBackground() :void {
      this.drawRoundRect(0, 0, this.width, this.height, 8, 0, 1, 0, null, null, null);
      }
      }
      }

      which is in cluded in an mxml page like this:

      <mx:Canvas width="100%" height="100%" label="Impressum" showEffect="WipeDown" hideEffect="WipeUp">
      <test:TestCanvasClass label="ffdsd" width="200" height="100">

      </test:TestCanvasClass>

      </mx:Canvas>