Is catalog misspelled?

categories = event.result.catelog.category;

If there's no catelog child of the XML root, then trying to access a child of that node will probably throw the error.

Doug

Roger Ross wrote:

Hello,

Working my way throught the "Training From the Source" turorial and
ran into this error message.

Not sure why I am getting it. I compared my code to the completed code
for the lesson and it looks the same with no problems when I compile it.

TypeError: Error #1009: Cannot access a property or method of a null
object reference.
at Dashboard/::catHandler()
at Dashboard/__catRPC_result()
at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at
mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent <http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent>()
at
mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler <http://www.adobe.com/2006/flex/mx/internal::resultHandler>()
at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at ::DirectHTTPMessageResponder/completeHandler()
at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()

Here is a copy of the code that it has me write with the comboBox that
is to receive the data:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml>"
layout="horizontal"
creationComplete="catRPC.send()">

<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;

[Bindable]
private var categories:ArrayCollection=new ArrayCollection();

private function catHandler(event:ResultEvent):void{
categories = event.result.catelog.category;
var catObj:Object = new Object();
catObj.name = "All";
catObj.categoryID = 0;
categories.addItemAt(catObj, 0);
catCombo.selectedIndex = 0;
}

]]>
</mx:Script>

<mx:HTTPService id="catRPC"
url="http://www.flexgrocer.com/category.xml <http://www.flexgrocer.com/category.xml>"
result="catHandler(event)"/>

<mx:ComboBox id="catCombo"
dataProvider="{categories}"
labelField="name"/>

Any Idea's...

Thanks,

Roger


Reply via email to