Loading Methods for External Files


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

Two different loading methods for external files.


Copy this code and paste it in your HTML
  1. package {
  2. import flash.display.Sprite;
  3. import flash.display.Loader;//Allows you to load an external file
  4. import flash.net.URLRequest;//This is used to reference the external file
  5. import flash.filters.DropShadowFilter;
  6.  
  7. public class LoadingMethods extends Sprite {
  8. public function LoadingMethods(){
  9. init();
  10. }
  11. private function init():void {
  12. /**
  13. Loading
  14. */
  15. var loader:Loader = new Loader();
  16. loader.load(new URLRequest("kitten.jpg"));
  17. addChild(loader);
  18. loader.x = 150;
  19. loader.y = 150;
  20. //For the loaded
  21. var ds2:DropShadowFilter = new DropShadowFilter(10, 45, 0x00ff00,1,3,2);
  22. var filterArray2:Array = [ds2];
  23. loader.filters = filterArray2;
  24.  
  25. /**
  26. Embedding
  27. **/
  28. //This is from importing the image into the lib and exporting for AS.
  29. var myImage:Kitten = new Kitten();
  30. addChild(myImage);
  31.  
  32. //For the embed
  33. var ds:DropShadowFilter = new DropShadowFilter(10, 45, 0xff0000,1,3,2);
  34. var filterArray:Array = [ds];
  35. myImage.filters = filterArray;
  36. }
  37. }
  38. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.