Xml – Flex: Why does setting scaleX/Y in mxml effect the components size but setting it in actionscript does not

apache-flexmxml

I'm playing around with the scaleX/Y in the canvas tag and have noticed some strange behaviour. When I set scale in in mxml the width and height of the canvas are adjusted accordingly. For example if I have a canvas like this:

<mx:Canvas width="1000" height="1000" scaleX="0.1" scaleY="0.1" /> 

The canvas now appears on screen to have a width and height of 100 and if inside my creationComplete callback I check the width and height property they are indeed 100.

But if I do exactly the same thing except I set the scaleX/Y property from actionscript the canvas on screen appears to have a width and height of 100 as expected, but when I check the width and height property of the canvas they are still at the previous values of 1000.

Could anyone help me understand what is going on and also tell me if there is any method that will refresh the width and height values so that they are correct?

Thanks,

Chris

Best Answer

At what point in the Canvas' lifecycle are you adjusting the scaleX/Y properties in Actionscript? And then, at what point are you re-checking them?

It may be helpful to examine this white paper on Flex component lifecycles (PDF) to pick the right timing for actionscript-based visual component tweaking.