0 Replies Latest reply on Mar 13, 2011 7:15 AM by verner45

    data Bind two custom components

    verner45

      Application file: has 2 custom components that sit in a comp folder (package)

       

      I just want to have the text typed in one component to update in real time with the other ... I am stumped ...

      I made both input fields public but cannot bind them any help is appreiciated

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955"
          minHeight="600" xmlns:comp="comp.*" creationComplete = "init();">
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <fx:Script>
              <![CDATA[
                  import spark.components.TextInput;
                  [Bindable]
                  public var mydatain:spark.components.TextInput= myReciever.recieve;
                  [Bindable]
                  public var mydataOut:spark.components.TextInput=mySender.dataOut;
                 
                  import mx.binding.utils.BindingUtils;
                 
                  private function init():void {
                      BindingUtils.bindProperty(mydataOut, "text", mydatain, "text");
                  }   
              ]]>
          </fx:Script>


        <comp:Reciever id="myReciever" width="171" height="94" x="44" y="108"/>  
        <comp:Sendinfo id="mySender"  x="44" y="27" height="73" width="167"/>
      </s:Application>


      recieve comp here "myReciever"

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx" width="162" height="72">
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <fx:Script>
              <![CDATA[
                  [Bindable]
                  public var dataIn:spark.components.TextInput = recieve;
              ]]>
          </fx:Script>
          <s:TextInput id="recieve"  x="17" y="40"/>
          <s:Label x="42" y="10" text="recieve"/>
      </s:Group>

       

      send Comp here

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx" width="174" height="66">
          <fx:Script>
              <![CDATA[
                 [Bindable]
                  public var dataOut:spark.components.TextInput = sender;
              ]]>
          </fx:Script>
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <s:TextInput id="sender" x="19" y="31"/>
          <s:Label x="48" y="10" text="sender"/>
      </s:Group>