Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 如何获得单选按钮&x27;s标签高度-AS3_Actionscript 3_Flash_Radio Button - Fatal编程技术网

Actionscript 3 如何获得单选按钮&x27;s标签高度-AS3

Actionscript 3 如何获得单选按钮&x27;s标签高度-AS3,actionscript-3,flash,radio-button,Actionscript 3,Flash,Radio Button,我想得到as3中radioButton的标签高度 我的单选按钮组中有5个单选按钮。其中一个单选按钮有三行标签,另一个单选按钮有一行标签等等 当我尝试访问单选按钮.height时,无论标签的高度如何,我都会得到相同的值 我需要知道标签的高度,以便可以相应地设置radioButton y坐标 我可以更改单选按钮的标签高度吗 spacing = 30; rb.label = tempQQString //from xml. long or short string anyone rb.group

我想得到as3中radioButton的标签高度

我的单选按钮组中有5个单选按钮。其中一个单选按钮有三行标签,另一个单选按钮有一行标签等等

当我尝试访问
单选按钮.height
时,无论标签的高度如何,我都会得到相同的值

我需要知道标签的高度,以便可以相应地设置radioButton y坐标

我可以更改单选按钮的标签高度吗

spacing = 30;
rb.label = tempQQString   //from xml. long or short string anyone
rb.group = myGroup;
rb.value = i + 1;

rb.x = answerX;
rb.y = questionField.height + (questionY+20) + (i * spacing); // here use rb.height or rb.textField.height 

trace("rb height**" + rb.height) // always get velue 22;
addChild(rb);
试试这个

for(var i=0;i<rb.numChildren;i++){
    if(rb.getChildAt(i) is TextField){
        var txt:TextField = rb.getChildAt(i) as TextField;
        trace(txt.height+":"+rb.height);//traces the height of text field and radio button 
    }
}
for(var i=0;i试试这个

for(var i=0;i<rb.numChildren;i++){
    if(rb.getChildAt(i) is TextField){
        var txt:TextField = rb.getChildAt(i) as TextField;
        trace(txt.height+":"+rb.height);//traces the height of text field and radio button 
    }
}

对于(var i=0;iRadioButton和任何扩展labelButton的fl控件(所有具有标签的控件),使用
.textField
属性公开实际文本字段

因此,对于您的示例,您可以使用
rb.textField.height
来获取控件标签部分的高度,而不是使用
rb.height

您还可以在文本字段上设置属性

rb.textField.background = true;
rb.textField.backgroundColor = 0xDDDDDD;

rb.textField.multiline = true;
rb.textField.wordWrap = true;
rb.textField.autoSize = TextFieldAutoSize.LEFT;

现在,对于您的场景,您最好只使用单选按钮的边界,因为它将是对象的真实高度

rb.getBounds(rb).height;  //this will be the true height of the component.

如果标签只有一行,且图标比标签高,则可能从rb.textField.height中获取的值小于单选按钮的实际高度。

单选按钮和任何扩展labelButton的fl控件(所有具有标签的控件),使用
.textField
属性公开实际文本字段

因此,对于您的示例,您可以使用
rb.textField.height
来获取控件标签部分的高度,而不是使用
rb.height

您还可以在文本字段上设置属性

rb.textField.background = true;
rb.textField.backgroundColor = 0xDDDDDD;

rb.textField.multiline = true;
rb.textField.wordWrap = true;
rb.textField.autoSize = TextFieldAutoSize.LEFT;

现在,对于您的场景,您最好只使用单选按钮的边界,因为它将是对象的真实高度

rb.getBounds(rb).height;  //this will be the true height of the component.

如果您的标签只有一行,并且您的图标比标签高,则可能从rb.textField.height中获得的值小于单选按钮的实际高度。

thanx回答:)我不知道“rb.getBounds(rb.height)”代码。尼斯:)请接受答案。这种方式比循环单选按钮的每个子元素,直到到达文本字段instance.thanx来回答:)我不知道“rb.getBounds(rb.height)”代码更高效、更干净。很好:)那么请接受答案。这种方式比循环遍历单选按钮的每个子元素直到到达文本字段实例更高效和干净。您使用的是哪个单选按钮类?你不能通过rb获得单选按钮标签的高度。高度
,它代表整个单选按钮组件的高度,标签是单选按钮的子项,它有自己的高度。是的,有时候,像radioButton这样的fl控件会覆盖真实高度,从而忽略标签,这是愚蠢的。没有必要回答。rb.textField.height是获取radioButton标签的高度。Thanx:)@SerdarAlkan-你真的在使用你选择的答案吗?你在使用哪个单选按钮类?你不能通过rb获得单选按钮标签的高度。高度
,它代表整个单选按钮组件的高度,标签是单选按钮的子项,它有自己的高度。是的,有时候,像radioButton这样的fl控件会覆盖真实高度,从而忽略标签,这是愚蠢的。没有必要回答。rb.textField.height是获取radioButton标签的高度。Thanx:)@SerdarAlkan-你真的在使用你选择的解决方案作为答案吗?