android - Resizing a Flash loader after Event.COMPLETE doesn't work -
google suggests following not uncommon question: having loaded flash stage using loader, want resize it. however, if before content loaded, resizing image causes disappear.
the proposed solution use event listener event.complete. here's code:
public function flixeltest() { super(); // support autoorients stage.align = stagealign.top_left; stage.scalemode = stagescalemode.no_scale; myloader = new loader(); myloader.x = (stage.fullscreenwidth-640)/2; myloader.y = (stage.fullscreenheight-480)/2; addchild(myloader); var url:urlrequest = new urlrequest("stuff.swf"); myloader.load(url); myloader.contentloaderinfo.addeventlistener(event.complete, loadprodcomplete); } function loadprodcomplete(e:event):void{ myloader.height = 480; myloader.width = 640; }
according every posting can find far online, solution should work. when event fires, loader done, , can resized. however, doesn't. commenting out lines modify .height , .width cause swf appear, uncommenting them , running again , swf never loads.
could else interfering here? using flashbuilder construct actionscript3 -> android project.
edit - solution here doesn't appear work either: problem resizing loader after loading swf
update - have working, , horrific, solution followed:
function loadprodcomplete(e:event):void{ if(myloader.width != 0){ myloader.width = 640; myloader.content.width = 640; } else{ timer = new timer(500); timer.addeventlistener(timerevent.timer, timertick); // there should comma here yahoo replaces ... timer.start(); } } function timertick(e:timerevent){ timer.stop(); stage.dispatchevent(new event(event.complete)); }
it uses content's width see if it's finished loading. if hasn't, waits half second , refires complete event. helps display (although width hasn't been adjusted, assume that's separate issue) - can't believe way working...
while not strictly solution, way i've circumvented not resizing @ - instead cropping area on window that's seen section wanted display.
function loadprodcomplete(e:event):void{ var gamemask : shape = new shape; gamemask.graphics.beginfill(0xffcc00); gamemask.graphics.drawrect(myloader.x,myloader.y,640,480); gamemask.graphics.endfill(); myloader.content.mask = gamemask; }
since mask would've been necessary me anyway hide off-stage clutter, solved 2 problems @ once.
i won't accept answer in case has alternative insights, if comes across question, posisble solution.
Comments
Post a Comment