1 Replies - 530 Views - Last Post: 17 March 2011 - 01:42 PM

#1 kevin_mchugh  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 70
  • Joined: 08-April 09

XML Event Handler Problem

Posted 17 March 2011 - 03:18 AM

I have a problem of which I am fairly certain their must be an easy solution. I am trying to use the Twitter Search API to retrieve a list of tweets and parse out all of the HashTags. My code works and does what I require....as long as what I am doing doesn't want to leave the necessary event handler. I have the following piece of code:

_loader.addEventListener(Event.COMPLETE, urlLoader_complete);
			
			function urlLoader_complete(evt:Event):void{
				_currentTweets = new XML(evt.target.data);
				_currentTweets = removeNS(_currentTweets);
				for(var x:int = 0; x<_currentTweets.entry.length(); x++){
					var $temp: String = _regExTag.exec(_currentTweets..title[x]);
					if( $temp != null)
					$topics.push($temp);
				}
			}




Now, please excuse my French but how the name of flying goose piss do I retrieve the XML file on completion? Actually what I want to get is my $topics list but I would settle for the XML file. NO matter what I do (The $topics list and _currentTweets are global variables) within the function/event handler....the changes only exists within the function/event handler.

I.E If I trace _currentTweets within then event handler it displays the whole thing, however if I do it after the event handler has run...._currentTweets returns to its original state of null. Like wise for the topics list.

I understand that you CANT return values from an event handler but as the Loader must use the event Handler it seems like the stupidest idea ever that you cannot affect the rest of the program with it.

Now, I may be just be being stupid here (Action Script is not my field, this is a Uni project) but could anyone please put me out of my misery? Or even suggest an alternative if I just cannot do what I want to with this piece of code?

Thanks for all the help. I hope me problem is clear and apologies if this is in the wrong place.

Later

Kevin

Is This A Good Question/Topic? 0
  • +

Replies To: XML Event Handler Problem

#2 kevin_mchugh  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 70
  • Joined: 08-April 09

Re: XML Event Handler Problem

Posted 17 March 2011 - 01:42 PM

To answer my own question and for anyone in the future who has this problem. This function wasnt finished running before I called it. Apparently action script runs simultaneously....so you need to slow the calling down/make it wait until the parsing has finished.

I hope that made sense. If not ask me to explain it better before it drives you mad :-)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1