Dynamic HTML/XML links in as3


/ Published in: ActionScript 3
Save to your folder(s)

So in this example I Pull an RSS feed and display it, then make the link a clickable HTML link styled with CSS.

Please feel free to punch holes in my code and help me make it leaner


Copy this code and paste it in your HTML
  1. var a:Object = new Object();
  2. a.color = "#fd0e08";
  3. a.fontWeight = ("bold");
  4. a.fontSize = 20;
  5.  
  6. var aHover:Object = new Object();
  7. aHover.fontSize = 20;
  8. aHover.color = "#cccccc";
  9.  
  10. var style:StyleSheet = new StyleSheet();
  11. style.setStyle("a", a);
  12. style.setStyle("a:hover", aHover);
  13.  
  14. textfeed0.styleSheet = style;
  15.  
  16. var xmlLoader:URLLoader = new URLLoader();
  17. var xmlData:XML = new XML();
  18.  
  19. xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
  20. xmlLoader.load(new URLRequest("http://www.associatedcontent.com/rss/rss_process.shtml?content_type=rover_feature&content_type_id=721602"));
  21.  
  22. function LoadXML(e:Event):void {
  23. xmlData=new XML(e.target.data);
  24. Parserover_feature(xmlData);
  25. }
  26.  
  27. function Parserover_feature(rover_feature:XML):void {
  28. textfeed0.htmlText = "<a href=\"http://www.yahoo.com\">"+rover_feature.items.item.title[0]+"</a>";
  29. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.