Posted By

arpo on 12/01/08


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

SmpleJohn
ebooksrfun
THEPWN3R


XML basics


 / Published in: ActionScript 3
 

Base for reading a XML file from URL

  1. package com
  2. {
  3. import flash.display.MovieClip;
  4. import flash.net.URLLoader;
  5. import flash.net.URLRequest;
  6. import flash.xml.*;
  7. import flash.events.*;
  8. import flash.errors.*;
  9.  
  10. public class RSS extends MovieClip
  11. {
  12. //Declarations
  13. protected var mainXML:XML;
  14. protected var loader:URLLoader;
  15.  
  16. public function RSS()
  17. {
  18. start();
  19. }
  20.  
  21. public function start():void
  22. {
  23.  
  24. loader = new URLLoader();
  25. loader.addEventListener(Event.COMPLETE, onComplete);
  26. loader.load(new URLRequest("http://www.gp.se/rss/index.jsp?d=100"));
  27.  
  28. }
  29.  
  30. protected function onComplete(e:Event)
  31. {
  32. try
  33. {
  34. //http://dispatchevent.org/roger/as3-e4x-rundown/
  35. mainXML = new XML(loader.data)
  36.  
  37. } catch(e:Error)
  38. {
  39. trace("Error: " + e.message)
  40. return;
  41. }
  42. }
  43.  
  44.  
  45. }
  46. }

Report this snippet  

You need to login to post a comment.