George Profenza
George Profenza

Reputation: 51837

How can I fix this potential bug with the RadioButton component?

I've got a weird issue with the RadioButton(fl.controls) when I add it to the stage.

Here's a quick way to reproduce the issue:

  1. create an empty MovieClip
  2. add a RadioButton component
  3. set the width of the component to a value smaller than 100
  4. trace the container width

The container width will trace 100 even though the RadioButton instance on stage is less than 100 wide.

If I add the component from code, it works if I invalidate the stage after adding the RadioButton first, then check the container width in a Event.RENDER handler.

Is there any fix for this measurement bug when adding the RadioButton manually in the IDE/Authoring ?

Upvotes: 0

Views: 130

Answers (1)

Alex
Alex

Reputation: 4934

This is because Flash uses a scaling ratio in order to resize objects at runtime, rather than using width and height measures.

So if you load the RadioButton and shrink its size, you are actually scaling by say 0.89 of the original size.

When you run the application, your RadioButton is still 100px wide, but scaled down by a ratio of 0.89 of the original.

If you trace the scaleX and scaleY properties of a resized and a non-resized RadioButton, you will see what I mean.

Check out this documentation for more:

http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7df3.html

Upvotes: 3

Related Questions