0 Replies Latest reply on Feb 19, 2008 9:38 AM by OffCourse

    Getting data from flex into actionscript and back

    OffCourse
      Hi

      I am using a datagrid which gets its data from an xml file. One of the columns is using a field which I would like to use within Actionscrip so that I can use the strchar function (to select just a part of the text in that field) and then back to the datagrid.

      How do I do this? Normally, with an itemrenderer i would use "source={data.fieldname}" to get the data. But when I open an actionscript instance, I am unable to turn that into a string so that I can use it.

      Another problem I am having with actionscript is that every single example code I try to use that has "var" and "trace" code lines returns errors. Even those copied from tutorials, which should work. Do I need to set up something?

      Source Code
      MXML File

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" creationComplete="catalog.send()">
      <mx:HTTPService url="data/catalog_BCA.xml" useProxy="false" id="catalog" />
      <mx:DataGrid dataProvider="{catalog.lastResult.Import.Auction}" width="100%" height="100%" x="0" bottom="0">
      <mx:columns>
      <mx:DataGridColumn headerText="" itemRenderer="TipoLeilaoRenderer" width="70"/>
      <mx:DataGridColumn headerText="Tipo de Leilão" dataField="SaleTypeName"/>
      <mx:DataGridColumn headerText="Data" dataField="SaleDate"/>
      <mx:DataGridColumn headerText="Date" itemRenderer="DateFormatter"/>
      <mx:DataGridColumn headerText="Local" dataField="BranchName"/>
      </mx:columns>
      </mx:DataGrid>
      </mx:Application>

      ITEMRENDERER
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Box xmlns:mx=" http://www.adobe.com/2006/mxml" >
      <mx:Script >
      <![CDATA[
      var str:String = {data.SaleCode};
      trace(str.slice(0,3));
      ]]>
      </mx:Script>
      </mx:Box>

      XML FILE

      <?xml version="1.0" encoding="UTF-8"?>
      <Import>
      <Auction>
      <CountryCode>PT</CountryCode>
      <SaleCode>880</SaleCode>
      <BranchCode>01</BranchCode>
      <BranchName>LISBOA</BranchName>
      <SaleDate>2008-01-31T18:00:00</SaleDate>
      <SaleTypeName>GE-Direct</SaleTypeName>
      <SaleDescription>GE-Direct LISBOA Jan 31 200</SaleDescription>
      <SaleCancelled>false</SaleCancelled>
      </Auction>
      <Auction>
      <CountryCode>PT</CountryCode>
      <SaleCode>881</SaleCode>
      <BranchCode>01</BranchCode>
      <BranchName>LISBOA</BranchName>
      <SaleDate>2008-01-31T10:15:00</SaleDate>
      <SaleTypeName>Online</SaleTypeName>
      <SaleDescription>Online LISBOA Jan 31 200</SaleDescription>
      <SaleCancelled>false</SaleCancelled>
      </Auction>

      </Import>

      Can anyone help me with this? Would the code I am trying to use

      Thank you