1
votes

Can anyone tell me, or point me to reading about, how a ScaleX/ScaleY event propagates down to the children of display object? I want to step in at some point and "re-scale" one of the children of a display object that has just been scaled with it's parent. I can't find any event that is fired, and ScaleX and width setters don't seem to be getting called on the child objects. I'm working on an ActionScript Project (not Flex) in FlashBuilder.

2
If you want a ScaleEvent to be fired, you'll have to extend a class and make a few custom overrides: override public function set scaleX( val:Number ):void { if ( this.dispatchEvent(...your event here...) ){ super.scaleX = val; } }. - zzzzBov

2 Answers

1
votes

scaleX, width, height, etc. are synchronous operations and there is no event fired. If you absolutely have to capture it in the setters, try overriding the setters in child components.

I did try that and it doesn't seem to work, if a property of a parent DisplayObject is being modified, its child components are not being touched. I guess it makes sense.

If you have access to parent components then you could intercept the setters over there.

0
votes

As already noted, there is no resizing event, and children scale with their parent (expected behavior).

If you wish to scale the container, and have the content children remain the same size on screen, you have to loop over the children and do one of the following to each child:

  • Apply to it the inverse of the transform matrix you used to scale the container
  • Scale it by 1/scale, where scale is factor you multiplied the parent scale by.

Scale changes on the parent change its whole coordinate space, so if you want your children to stay the same size and stay in the same place relative to the parent's (0,0) point, you need to apply the 1/scale to their x and y positions also.