1 Reply Latest reply on Jun 29, 2009 1:58 PM by seidleroni

    How to bind XML in Actionscript?


      I'm having difficulty working with binding in actionscript.  In MXML I can use the following line:

      <mx:Label x="117" y="40" text=" {stationXML.getItemAt(Station-1).CDL0.@value}" id="lblTest"/>


      However, in actionscript, I cannot seem to get the binding to work! I tried the following:




      Any ideas how I can do this in Actionscript?  I need to do it in ActionScript becuase the "CDL0" value will need to be replaced at times with "CDL1", "CDL2", etc...

        • 1. Re: How to bind XML in Actionscript?
          seidleroni Level 1

          I solved the issue, so if anyone else has the same problem, here's what I did (after much aggravation):


          The reason I didnt use MXML binding was because I wanted to be able to change it from "CDL0" to "CDL1" to "CDL3" without manually changing bindings.


          What I set in MXML for the text was:



          where 'cdlstr' was a public string declared (and set) elsewhere in the program.


          So I could make 'cdlstr' = "CDL0" or "CDL1" or even "CDL" + i (if I wanted to make life easy).  Just needed to remember to make 'cdlstr' a bindable variable or else it all falls apart.


          Hope it helps someone else.