actionscript 3 - I want to scale swf up to 100%, but at any percent down. Any ideas how to do that? -
i want allow swf scale when browser window resized, don't want increase on 100% (so should scale down).
this example of kind of scaling client wants: http://www.voosfurniture.com/
but again, should stop @ 100% going up.
you can need put content in container (variable "_container" below) :
package { import flash.display.sprite; import flash.display.stagealign; import flash.display.stagescalemode; import flash.events.event; import flash.geom.point; import flash.geom.rectangle; public class test extends sprite { private var _initialestagebounds : point = new point; private var _container : sprite = new sprite; public function test() { _container.graphics.beginfill(0x556699); _container.graphics.drawrect(0,0,100,100); addchild(_container); _initialestagebounds.x = stage.stagewidth; _initialestagebounds.y = stage.stageheight; stage.scalemode = stagescalemode.no_scale; stage.align = stagealign.top_left; stage.addeventlistener(event.resize, onstageresize); } private function onstageresize(e:event) : void { var ratio : number = math.min(1, stage.stagewidth / _initialestagebounds.x, stage.stageheight / _initialestagebounds.y); _container.x = (stage.stagewidth - _container.width) / 2; _container.y = (stage.stageheight - _container.height) / 2; _container.scalex = ratio; _container.scaley = ratio; } } }
Comments
Post a Comment