Advertisement
Guest User

Untitled

a guest
Jul 18th, 2013
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. import flash.display.Bitmap;
  2.  
  3. //creates a loader for each picture to be loaded, I know I could have an empty array that I add to but created a full array to test.
  4.  
  5. var loaders:Array = [new Loader(),new Loader(), new Loader(), new Loader(), new Loader(), new Loader(), new Loader(), new Loader(), new Loader(), new Loader()];
  6.  
  7. //stores the url request for each image to be loaded
  8.  
  9. var Requests:Array =[new URLRequest("pic1.jpg"),new URLRequest("pic2.jpg"),new URLRequest("pic3.jpg"),
  10. new URLRequest("pic4.jpg"),new URLRequest("pic5.jpg"),new URLRequest("pic6.jpg"), new URLRequest("pic7.jpg"),
  11. new URLRequest("pic8.jpg"), new URLRequest("pic9.jpg"),new URLRequest("pic10.jpg")];
  12.  
  13.  
  14.  
  15. //creates 2 empty arrays one to store the thumbnail sized pics the other fullsized. Ideally I want one Array holding the bitmap data and the other holding the thumbnail instances since I only need 2
  16. // fullsized images at a time I can just create a new one and erase the old one in a single function.
  17.  
  18. var pics:Array = new Array();
  19. var pics2:Array = new Array();
  20.  
  21. //defines an empty bitMap variable as a placeholder for which to copy from redefined in every iteration of the loop
  22.  
  23. var test:Bitmap;
  24.  
  25. //loops through every loader
  26.  
  27. for (var i in loaders);
  28. {
  29. // loads the loader and url request and creates a picture
  30. loaders[i].load(Requests[i]);
  31.  
  32. //waits for the pic to load
  33. loaders[i].contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
  34.  
  35. //after loader is loaded create pic from the data
  36. function loadComplete(evt:Event):void
  37. {
  38. var i = "Test";
  39. trace(i);
  40. test= evt.target.content as Bitmap;
  41. pics2[i] = test;
  42. pics[i] =new Bitmap(test.bitmapData);
  43. pics2[i] =new Bitmap(test.bitmapData);
  44.  
  45. //creates an image on the stage at runtime to help debug
  46.  
  47. var pic1 = new Bitmap(test.bitmapData);
  48. addChild(pics[i])
  49. pic1.scaleX = 0.138427734375;
  50. pic1.scaleY = 0.1384114583333333;
  51. pic1.x = 204;
  52. pic1.y = 20.6;
  53. pic1.alpha = .25;
  54.  
  55. var pic2:Bitmap = new Bitmap(test.bitmapData);
  56. pic2.x =100;
  57. pic2.y =100;
  58. pic2.scaleX =.33;
  59. pic2.scaleY=.33;
  60. addChild(pic2);
  61. loaders[i].contentLoaderInfo.removeEventListener(Event.COMPLETE, loadComplete)
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement