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 ?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top