I am having fits trying to figure out how to use the information coming back
from a webservice. I created a web service call in my code:
<mx:WebService id="storyGateway"
wsdl="http://www2.med.umich.edu/prmc/media/newsroom/stories.cfc?wsdl"
fault="Alert.show(event.fault.message,'Story Gateway Error')">
<mx:operation name="listBySubject" result="buildBookHandler(event)"
fault="Alert.show(event.fault.message,'Story Gateway Error')" />
</mx:WebService>
It returns the data as requested, I can see it in my debugging, but I cannot
figure out how to set it to a variable and then call the various elemenets
(linkText, story, photo, defaultLogo)
I tried to set it to a variable as an ArrayCollection:
[Bindable]
public var storyFeed:ArrayCollection = new ArrayCollection();
public function buildBookHandler(e:ResultEvent):void {
storyFeed = e.result as ArrayCollection;
for (var i:uint = 0; i < e.result.data.length; i++){
...
//Story Area
var storyArea:TextArea = new TextArea();
storyArea.text = storyFeed.getItemAt(i).story;
storyArea.wordWrap = true;
storyArea.height = 550;
storyArea.width = 400;
storyArea.editable = false;
magPage.addChild(storyArea);
storyArea.x = 0;
storyArea.y = 25;
...
}
rssMag.flipOnClick = true;
}
But still getting errors..
TypeError: Error #1009: Cannot access a property or method of a null object
reference.
at RSSMagazine/buildBookHandler()[D:\wkolcz\My Documents\Flex Builder
3\RSSMagazine\src\RSSMagazine.mxml:36]
Line 36 is:
storyArea.text = storyFeed.getItemAt(i).story;
Help!