1

我想使用标注来允许重命名。标注包含通过绑定填充的 textInput(嵌入在组件中)。每次打开标注时都会使用不同的文本。不幸的是,每次只显示第一个文本,无论我可以写入绑定数据。我附上了一个样本。

我注意到,当标注关闭时将组件附加到视图,然后重新附加到标注,文本输入会正确更新。

欢迎任何帮助。

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" title="TestChgCallout2"
creationComplete="init()"
>

<fx:Declarations>
    <s:Callout id="COrename"/>
    <fx:Component className="Rename">
        <s:VGroup>          
            <fx:Metadata>
                [Event(name="cancel", type="flash.events.Event")]
                [Event(name="updated", type="flash.events.Event")]
            </fx:Metadata>

            <fx:Script>
            <![CDATA[
                [Bindable] private var _nom:String="";
                private var _NewName:String="";

                public function set nom(s:String):void {
                    _nom=s;
                    _NewName="";
                }

                public function get nom():String {
                    return _NewName;
                }

                private function doUpd():void {
                    var req:XML=<req><oldName></oldName><newName></newName></req>;
                    req.oldName = _nom;
                    req.newName = Nom.text;
                    _NewName=Nom.text;
                    this.dispatchEvent(new Event('updated'))
                }
            ]]>
            </fx:Script>


            <s:HGroup verticalAlign="middle">
                <s:Label width="90" text="Nom" verticalAlign="middle"/>
                <s:TextInput id="Nom" text="{_nom}" width="201" maxChars="23" restrict="a-z A-Z0-9" />
            </s:HGroup>
            <s:HGroup width="100%" verticalAlign="middle" horizontalAlign="center">
                <s:Button label="cancel" click="this.dispatchEvent(new Event('cancel'))"/>
        <s:Button label="update" click="doUpd()"/>
            </s:HGroup>
        </s:VGroup>
    </fx:Component>
</fx:Declarations>


<s:HGroup gap="5">
    <s:VGroup>
    <s:Label text="{'Count:' + i.toString()}" />
    <s:Label text="{'result:' + _res}" />
    </s:VGroup>
         <s:Button id="Bt" label="call" click="doCall()" />
</s:HGroup>

<fx:Script>
<![CDATA[
        [Bindable] private var i:int=0;
        private var renPlan:Rename = new Rename();
        [Bindable] private var _res:String="";

        private function init():void {
            renPlan.addEventListener("cancel", onPlanUpdCancel);
            renPlan.addEventListener("updated", onPlanUpdated);
            COrename.addElement(renPlan);
        }

        private function doCall():void {
            if (COrename.isOpen) {
                COrename.close();
            } else {
                renPlan.nom = "test #"+i.toString();
                COrename.open(Bt, false);
            }
        }

        private function onPlanUpdCancel(e:Event):void {
            i++;
            COrename.close();
        }

        private function onPlanUpdated(e:Event):void {
            i++;
            _res = renPlan.nom;
            COrename.close();
        }
    ]]>
    </fx:Script>

</s:View>
4

1 回答 1

0

对于这些情况,您是否尝试过通常的建议——更换皮肤

<s:TextInput skinClass="spark.skins.mobile.TextInputSkin" id="Nom" 
text="{_nom}" width="201" maxChars="23" restrict="a-z A-Z0-9" />
于 2012-11-21T08:43:28.987 回答