I'm learning flex and Flash Builder 4.6 and doing a small example project.
I've created a mobile app test using a web service. I got the web service to work, creating xml dataset. I can get the flex code to access the web service and read the file. That works so far. The code reads the whole xml file from the web service and presents it. What I don't quite see is how to read only the elements. When I specify the .LastResult.element.element I get Error #1009: Cannot access a property or method of a null object reference. during runtime.
I can post the webservice xml result if that helps. Thanks for any insights.
Here's the code
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="view1_creationCompleteHandler(event)"
xmlns:service1="services.service1.*"
xmlns:uws_lookups="services.uws_lookups.*"
title="HomeView">
<fx:Script>
<![CDATA[
import mx.rpc.soap.WebService;
import mx.collections.ArrayCollection;
import mx.rpc.AsyncResponder;
import mx.collections.XMLListCollection;
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;
import spark.events.IndexChangeEvent;
import spark.events.TextOperationEvent;
]]>
</fx:Script>
<fx:Declarations>
<s:WebService
id="SampleDBwebserviceCS"
wsdl="http://localhost:57074/Service1.asmx?WSDL"
showBusyCursor="true"
useProxy= "false"
makeObjectsBindable="true">
<s:operation name="Getmember" resultFormat="xml">
</s:operation>
</s:WebService>
<s:CallResponder id="GetmemberResult"/>
<service1:Service1 id="service1"/>
</fx:Declarations>
<s:VGroup width="60%" height="60%" color="#10851E" fontFamily="Arial" fontSize="10"
fontWeight="normal" horizontalAlign="center" verticalAlign="middle">
<s:TextArea id="lblResult" x="2" y="0" width="188" height="234"
creationComplete="view1_creationCompleteHandler(event)"
text="{GetmemberResult.lastResult}">
</s:TextArea>
<!-- Returns the whole xml result - all fields all xml definitions -->
<!-- Want to return GetmemberResult.lastResult.Sales.FirstName -->
<!-- however this causes a 1009 error on Sales-->
<s:Button
label="Get Data"
click="SampleDBwebserviceCS.Getmember.send(); lblResult.text = SampleDBwebserviceCS.Getmember.lastResult"
x="10"
y="568">
</s:Button>
</s:VGroup>
</s:View>
1009 error when I insert this property in the <s:Button tag:
click="SampleDBwebserviceCS.Getmember.send(); lblResult.text = SampleDBwebserviceCS.Getmember.lastResult.Sales.FirstName"
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at views::SampleSQLHomeView/___SampleSQLHomeView_Button1_click()[C:\User s\phillip\Adobe Flash Builder 4.6\SampleSQL\src\views\SampleSQLHomeView.mxml:121]