2 Replies Latest reply on Apr 12, 2008 2:07 PM by jlopes151

    Data binding will not be able to detect assignment to variable v2

    jlopes151 Level 1
      Here's the class

      package com
      {
      public class Boston
      {
      [Bindable]
      public var v1:Number = 0;
      public var v2:Number = 0;

      public function Boston()
      {
      v1 = new Number();
      v2 = new Number();
      }

      public function addToV1(value:Number):void {
      this.v1 += value;
      }

      public function addToV2(value:Number):void {
      this.v2 += value;
      }

      public function getFromV1():Number {
      return v1;
      }

      public function getFromV2():Number {
      return v2;
      }

      public function testAdd():void {
      var test:Number = 10;
      var count:Number = 0;

      while(count <= test){
      addToV1(count);
      addToV2(count + 4);

      count++;
      }
      }
      }
      }


      The Application

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
      creationComplete="init();">
      <mx:Script>
      <![CDATA[
      import com.Boston;

      [Bindable]
      public var boston:Boston = new Boston();
      [Bindable]
      public var single:Number = new Number();

      [Bindable]
      public var rip:Object = new Boston();

      public function init():void {
      boston.testAdd();
      boston.addToV2(34);
      single = boston.getFromV2();
      }
      ]]>
      </mx:Script>

      <!-- Get the alert here that the data binding will not detect assignments to var v2 -->
      <mx:Text text="{boston.v2}"/>

      </mx:Application>