Posted By

antpaw on 01/28/09


Tagged

xml actionscript3


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

enajenkins
ClayVillage


XML Loop in ActionScript 3


 / Published in: ActionScript 3
 

and DropShadow Filter :)

  1. // XML LOAD
  2. var myXML:XML = new XML();
  3. var XML_URL:String = "newsXML.xml";
  4. var myXMLURL:URLRequest = new URLRequest(XML_URL);
  5. var myLoader:URLLoader = new URLLoader(myXMLURL);
  6. myLoader.addEventListener("complete", xmlLoaded);
  7.  
  8.  
  9. // HEADLINE
  10. var headLineFormat:TextFormat = new TextFormat();
  11. var headLineX:Number = 0;
  12. var headLineY:Number = 0;
  13.  
  14. headLineFormat.color = 0xFFFFFF;
  15. headLineFormat.font = "Arial";
  16. headLineFormat.size = 36;
  17. headLineFormat.bold = true;
  18.  
  19.  
  20. var shadowHL:DropShadowFilter = new DropShadowFilter();
  21. shadowHL.color = 0x000000;
  22. shadowHL.blurY = 12;
  23. shadowHL.blurX = 12;
  24. shadowHL.alpha = 1;
  25. shadowHL.distance = 0;
  26. var filtersArray:Array = new Array(shadowHL);
  27.  
  28.  
  29. function xmlLoaded(event:Event):void
  30. {
  31. myXML = XML(event.target.data);
  32. for (var i:Number = 0; i < myXML.news.headline.length(); i++)
  33. {
  34. // HEADLINE
  35. var headLine:TextField = new TextField();
  36. addChild(headLine);
  37. headLine.text = myXML.news[i].headline;
  38. headLine.y = headLineY;
  39. headLine.x = headLineX;
  40. headLine.width = 70;
  41. headLineY -= 50;
  42. headLine.wordWrap = true;
  43. headLine.autoSize = TextFieldAutoSize.LEFT;
  44. headLine.setTextFormat(headLineFormat);
  45. headLine.filters = filtersArray;
  46. }
  47. }

Report this snippet  

You need to login to post a comment.