actionscript 3 - As3 loading blank image -


i'm having problems loading image externall source (this working changed server https , made adjustments). now, when loaded image, there no errors, width, height 0. image blank. tried loading script random internet image , worked fine. original - (https://www.lovemarks.co/images/be50fe37eac192fb7c0d17353f5ef993a.jpg) - doesn't work.

var somethingloaded:boolean = true; var actualpic:*; var pictldrx:loader = new loader(); var picturlx:string = 'https://www.lovemarks.co/images/be50fe37eac192fb7c0d17353f5ef993a.jpg'; var picturlreqx:urlrequest = new urlrequest(picturlx); var loadercontext:loadercontext = new loadercontext(); pictldrx.load(picturlreqx); pictldrx.contentloaderinfo.addeventlistener(event.init , loadedremember)                      function loadedremember(event:event){     var targetloader:loader = loader(event.target.loader);     var newmc:movieclip = new movieclip();     addchild(newmc);     newmc.addchild(targetloader.content);     newmc.x = -targetloader.width/2;     newmc.y = -targetloader.height/2;     trace ('w+'+targetloader.width);          trace ('h+'+targetloader.height);     trace ('x+'+newmc.x);     trace ('y+'+newmc.y);    } 

the way first listen event.complete instead of event.init:

pictldrx.contentloaderinfo.addeventlistener(event.complete , loadedremember); 

then, instead of referencing actual loader in handler, reference image directly first casting event.target.content bitmap:

function loadedremember(event:event) {     trace("loadedremember()");      var newmc:bitmap = bitmap(event.target.content);     addchild(newmc);     // math center may need adjusted     // account such big image size     newmc.x = -newmc.width/2;     newmc.y = -newmc.height/2;      trace ('w+'+newmc.width + '\nh+'+newmc.height + '\nx+'+newmc.x + '\ny+'+newmc.y);    } 

additionally check security errors related cross domain within output window.


Comments