2012-11-20 29 views
1

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

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

任何帮助将受到欢迎。

<?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> 

回答

0

您是否尝试过这些情况下的常见建议 - to change the skin

<s:TextInput skinClass="spark.skins.mobile.TextInputSkin" id="Nom" 
text="{_nom}" width="201" maxChars="23" restrict="a-z A-Z0-9" /> 
+0

非常感谢,这工作。我的错误,我看到了这个建议,但从未测试过,因为我没有在我的问题和这个建议之间找到任何共同点。 – serge