Posted By

merrittwjm on 03/31/11


Tagged

php variables flash load vars as3


Versions (?)

Flash get PHP vars


 / Published in: ActionScript 3
 

  1. package
  2. {
  3. import flash.display.Sprite;
  4. import flash.events.*;
  5. import flash.net.URLLoader;
  6. import flash.net.URLLoaderDataFormat;
  7. import flash.net.URLRequest;
  8.  
  9. public class URLLoaderDataFormatExample extends Sprite
  10. {
  11. public function URLLoaderDataFormatExample()
  12. {
  13. var request:URLRequest = new URLRequest("http://www.[yourdomain].com/params.txt");
  14. var variables:URLLoader = new URLLoader();
  15. variables.dataFormat = URLLoaderDataFormat.VARIABLES;
  16. variables.addEventListener(Event.COMPLETE, completeHandler);
  17. try
  18. {
  19. variables.load(request);
  20. }
  21. catch (error:Error)
  22. {
  23. trace("Unable to load URL: " + error);
  24. }
  25. }
  26. private function completeHandler(event:Event):void
  27. {
  28. var loader:URLLoader = URLLoader(event.target);
  29. trace(loader.data.varName);
  30. }
  31. }
  32. }

Report this snippet  

You need to login to post a comment.