Skip to main content
Inspiring
April 6, 2009
Question

Determing the scale of a component

  • April 6, 2009
  • 1 reply
  • 1822 views

The context for this is a bug I'm trying to fix (#SDK-19578) where if a   component/application has a scaleX/scaleY applied to it, the tool tip appears   at the default scale and so looks too big/small.

Our specific case is using application.scaleX / scaleY in an AIR application   to make it easier to read for vision impaired users.  

My first attempt only addressed this specific case, so I would do

  currentToolTip.scaleX = (currentTarget as UIComponent).parentDocument.scaleX

though I commented on the issue maybe .parentApplication would be better.  

Corey Lucier however makes the very good point that you can't assume the scale   of 'this' component (a page in a viewStack) is the same as the overall scale   of the whole application - any of the intermediate components could have a   scale applied.  

So...  is the correct approach more like: 

  scale=1

  item=parent

  while (item.parent)

    scale=scale*item.scale

    item=item.parent

  wend

  currentToolTip.scale=scale

?

This topic has been closed for replies.

1 reply

Participant
April 7, 2009

Tom,

You can get the concatenated transforms by accessing the DisplayObject.transform.concatenatedMatrix property. The a and d properties of the Matrix should give you the scale. However, if your displayObject is rotated, you'll have to factor that out. The mx.geom.CompoundTransform class has a decomposeMatrix function that implements this logic.

Jason

Inspiring
April 15, 2009

Would that tie the code to Player 10 only or anything ?