【问题标题】:Flex: Binding to the Height of the UITextFieldFlex:绑定到 UITextField 的高度
【发布时间】:2010-10-04 20:13:19
【问题描述】:

我在将 UITextField 的高度绑定到 VBox 的 y 和 TitleWindow 的高度时遇到问题。我正在尝试调整 TitleWindow 的高度和 VBox 的高度,以便 UITextField 不会与其他内容重叠。

或者,我尝试将 UITextField 的高度设置为明确的高度,但我无法让它工作。

我必须使用 UITextField 而不是 Text,因为我使用的是 Flash Eff2。

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute" 
    width="520"  
    height="{tf.height + 380}">



<mx:Script>
    <![CDATA[
        import mx.core.UITextFormat;
        import mx.events.ItemClickEvent;

        import mx.controls.RadioButton;
        import mx.controls.RadioButtonGroup;
        import mx.core.UITextField;

        import mx.managers.PopUpManager;


        [Bindable]
        public var tf:UITextField = new UITextField;

        [Bindable]
        public var myText:String;

        [Embed(source="../libs/arial.ttf", fontFamily="ArialEmbedded")]
            public const ArialEmbedded:Class;

        public function createEffect2():void{

                tf.autoSize = TextFieldAutoSize.LEFT;
                //tf.height=150;
                tf.embedFonts = true;
                tf.multiline = true;
                tf.text = myText;
                tf.width = 400;
                tf.wordWrap = true;

                var myFormat:TextFormat = new TextFormat;
                myFormat.size = 25;
                myFormat.blockIndent=50;

                this.addChild(tf);
                tf.validateNow();
                tf.setTextFormat(myFormat);
                } 

    ]]>
</mx:Script>



        <mx:VBox  x="180" y="{tf.height + 140}"  width="480"  >
            <mx:RadioButtonGroup id="choicesRadioButtonGroup" />
                <mx:RadioButton  groupName="choicesRadioButtonGroup" label="A" horizontalCenter="150"/>
                <mx:RadioButton  groupName="choicesRadioButtonGroup" label="B" horizontalCenter="150"/>
                <mx:RadioButton  groupName="choicesRadioButtonGroup" label="C" horizontalCenter="150"/>
        </mx:VBox>



</mx:TitleWindow>

我得到:数据绑定将无法检测到“高度”的分配。

有什么建议吗?

谢谢。

-拉克西米迪

【问题讨论】:

    标签: apache-flex binding height uitextfield


    【解决方案1】:

    如果我不得不猜测,Binding 是一个 Flex 构造,而不是“ActionScript”构造。Height 是 UIComponent 中的可绑定对象,但 UITextField 不扩展 UIComponent。相反,它扩展了 FlexTextField,它扩展了 TextField(A Closed source Flash 类)。

    您可以扩展 UITextField 并覆盖高度以使其可绑定,或者仅使用扩展 UIComponent 的 Flex TextInput 类。

    【讨论】:

    • 您好 www.Flextras.com,谢谢您的留言。我还尝试使用显式值设置 UITextField 和 TitleWindow 的高度,但格式被搞砸了。我让 UITextField 在 TitleWindow 的左侧垂直向下运行一个字符宽。如果我删除高度,那么它可以正常工作。 (虽然,我必须将verticalScrollPolicy 设置为关闭)。有点奇怪。
    • 感谢您的支持。你的问题解决了吗?如果是这样,请将我的问题标记为答案。 [或发布您的替代解决方案并将其标记为答案]。
    猜你喜欢
    • 2013-02-24
    • 2011-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-10
    • 2017-12-27
    相关资源
    最近更新 更多