2 Replies Latest reply on Nov 23, 2010 10:07 PM by evolphin

    Changing scaleX/scaleY on parent scales the children but doesn't update  height/width property ?

    tbd2

      have created a custom component - MyImage - that has two children including a Bitmap as well as a Sprite.

      My display object hierarchy is as follows -

       

       

       

      mx:Canvas
        view
      :MyImage
           mx
      :Bitmap
          
      my:Sprite

       

       

       

       

      If I change the MyImage.scaleX, scaleY property, the children scale as I would expect them to.

      However when I try to place the children in the center using placeAgain() on getting a resize event:

       

       

          public function placeAgain():void
         
      {
             
      if (image==null) return;

             
      var pCanvas:Canvas = this.parent as Canvas;
             
      if (image.width <= pCanvas.width)
             
      {
                  pCanvas
      .horizontalScrollPolicy="off";
                  image
      .x = (pCanvas.width -image.width)/2;
             
      }
             
      else
             
      {
                  pCanvas
      .horizontalScrollPolicy="on";
                  image
      .x=0;
             
      }
             
      if (image.height <= pCanvas.height)
             
      {
                  pCanvas
      .verticalScrollPolicy="off";
                  image
      .y = (pCanvas.height -image.height)/2;
             
      }
             
      else
             
      {
                  pCanvas
      .verticalScrollPolicy="on";
                  image
      .y=0;
             
      }
              alignKids
      ();
         
      }

      I find the image.height & width have not changed despite the image getting scaled!

      Isn't the child supposed to have its bounds changed after scaling its parent ? Especially after the child has actually been scaled correctly ? Why are bounds of the child stuck at the same value as before scaling? I am not caching the Bitmap, have not turned on caching of bitmaps.