Hi Everyone,
I am trying to parse some XML i have retrieved via e4x in an HTTPService. The loop works and for each episode in the list it goes through the loop. However i get the following error when it is trying to append to an XMLList.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
I am trying to query the local SQLite database and see if the episode exists (working) and if it does append to one xmllist and if not then append to the other xmllist.
public static function seasonFavHandler(evt:ResultEvent):void {
Application.application.ManagePage.selectedShow =
Application.application.ManagePage.gridFavourites.selectedItem as XML;
episodeNumber = XML(evt.result).descendants("episode");
var episode:Object = episodeNumber;
for each(episode in episodeNumber) {
currentEpisode = episode as XML;
achkStatement = new SQLStatement();
achkStatement.sqlConnection = dbconnection;
achkStatement.text = "select :episodename from episodes where episodename = :episodename";
achkStatement.parameters[":episodename"] = episode.title;
achkStatement.addEventListener(SQLEvent.RESULT, episodeHandler);
achkStatement.execute();
trace(episode.title);
}
//Application.application.ManagePage.episodeList = episodeNumber;
seasonHttpService.removeEventListener(ResultEvent.RESULT, seasonFavHandler);
CursorManager.removeBusyCursor();
}
private static function episodeHandler(event:SQLEvent):void {
var result:SQLResult = achkStatement.getResult();
var episodeNewT:XMLList;
var episodeWatchedT:XMLList;
if (!result.data) {
episodeNewT.appendChild(currentEpisode);
//Application.application.ManagePage.gridUnwatched.addChild(currentEpisode);
} else {
episodeWatchedT.appendChild(currentEpisode);
//Application.application.ManagePage.gridWatched.addChild(currentEpisode);
}
Application.application.ManagePage.episodeNew = episodeNewT;
Application.application.ManagePage.episodeWatched = episodeWatchedT;
achkStatement.removeEventListener(SQLEvent.RESULT, episodeHandler);
}