Posted By

StrawMan on 05/28/09


Tagged

utility as3 URLLoader


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

sidneydekoning


Loader builder utility function (URLLoader & Loader)


 / Published in: ActionScript 3
 

  1. private var _loaderformat:String;
  2. private var _loadURL:String;
  3. private var _loadertype:String;
  4. //////////////////////////////
  5. //URL Loader builder.
  6. //Text/Binary & SWF/Image objects.
  7. //////////////////////////////
  8. public function urlLoaderBuilder (_loadURL, _loaderformat = 'text', _loadertype = 'urlloader') {
  9. var req:URLRequest = new URLRequest(_loadURL);
  10. switch(_loadertype) {
  11. case 'urlloader':
  12. var urlloader:URLLoader = new URLLoader();
  13. urlloader.load (req);
  14. switch(_loaderformat) {
  15. case 'text':
  16. urlloader.dataFormat = URLLoaderDataFormat.TEXT;
  17. break;
  18. case 'variables':
  19. urlloader.dataFormat = URLLoaderDataFormat.VARIABLES;
  20. break;
  21. case 'binary':
  22. urlloader.dataFormat = URLLoaderDataFormat.BINARY;
  23. break;
  24. }
  25. return urlloader;
  26. break;
  27. case 'loader':
  28. var loader:Loader = new Loader();
  29. loader.load (req);
  30. return loader;
  31. break;
  32. }
  33. }
  34. //////////////////////////////

Report this snippet  

You need to login to post a comment.