Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.37 KB | None | 0 0
  1. Main.hx
  2.  
  3. private function tempload()
  4. {
  5.     var imageLoader:URLLoader = new URLLoader();
  6.     imageLoader.dataFormat = URLLoaderDataFormat.BINARY;
  7.     var request:URLRequest = new URLRequest("../../../Assets/data/homer.png");
  8.     imageLoader.addEventListener(Event.COMPLETE, completeHandler);
  9.     imageLoader.load(request);
  10. }
  11.  
  12. private function completeHandler(e:Event)
  13. {
  14.     var byteArrayData = e.currentTarget.data;
  15.     zoomBox.loadImage(byteArrayData);
  16. }
  17.  
  18.  
  19. ZoomBox.hx
  20.  
  21. public function loadImage(data:ByteArray)
  22. {
  23.     var bd:BitmapData = new BitmapData(Std.int(width), Std.int(height));
  24.     bd.setPixels(imageRect, data);
  25.    
  26.     var loadedImage = bd;
  27.     var baseImage = new Bitmap(loadedImage);
  28.    
  29.     stageImage = new BitmapWrapper(baseImage);
  30.     attachImageToHUD(stageImage, Std.int(imageRect.x), Std.int(imageRect.y));
  31.    
  32. }
  33.  
  34. Output:
  35.  
  36. [Fault] exception, information=Error: Error #2030: End of file was encountered.
  37.     at flash.display::BitmapData/setPixels()
  38.     at scripts::ZoomBox/loadImage()[C:\Users\SadiQ\AppData\Roaming\Stencyl\stencylworks\games-generated\testings\Source\scripts\ZoomBox.hx:107]
  39.     at scripts::MainScene/completeHandler()[C:\Users\SadiQ\AppData\Roaming\Stencyl\stencylworks\games-generated\testings\Source\scripts\MainScene.hx:110]
  40.     at flash.events::EventDispatcher/dispatchEventFunction()
  41.     at flash.events::EventDispatcher/dispatchEvent()
  42.     at flash.net::URLLoader/onComplete()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement