0 Replies Latest reply on Dec 5, 2010 5:28 AM by deivit_78

    variable detecting change

    deivit_78

      Hello, i'm learning about flex and actionscript and now i'm creating two components, one is a dropDownlist that is connecting to a database and shows several values, this one is ok. The value selected is returned to the main application, and this send as a parameter to the second component. The problem is: how can i detect the change of this parameter inside of the second component?.

       

      I was done http://livedocs.adobe.com/flex/3/html/help.html?content=databinding_7.html

       

      but this does not work for me.

       

      I put the second component code below:

       

      <?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="514" height="156"
               creationComplete="init()">

       

          <fx:Script>
             
              <![CDATA[
                         
                  import mx.controls.Alert;   
                  import mx.binding.utils.*;
                  import mx.events.FlexEvent;       
                         
                  [Bindable]
                  public var p_grupo:String;           
                  private function init():void
                  {   
                      var watcherSetter:ChangeWatcher =
                          BindingUtils.bindSetter(watcherListener, id_label, "text");
                  }   
                         
                  public function watcherListener(val:String):void {               
                          id2_label.text =val;
                  }       
              ]]>
          </fx:Script>
             
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
         
          <s:Label id="id_label" x="145" y="61" text="{p_grupo}"/>
          <s:Label id="id2_label" x="145" y = "80" text="" />

       

      </s:Group>

       

       

      Why update the id_label data, but not is detecting the change?

       

      Thanks for a lot