繁体   English   中英

如何在as3中调整resize事件期间设置舞台的宽度和高度

[英]how to set width and height for stage during resize event in as3

我想在调整swf的大小期间设置舞台的宽度和高度..我在调整大小事件处理时这样做但是不起作用..实现这个的其他方法?

 stage.addEventListener (Event.RESIZE, resizeListener);

 function resizeListener (e:Event):void {
  stage.stageWidth=500;
  stage.stageHeight=300;

 }

谢谢

通过它你只需要它的声音

 stage.align     = "";
 stage.scaleMode = StageScaleMode.NO_SCALE;

无论您拉伸多少窗口,这都将使内容保持相同的大小

Updated:

您需要比较内容和目标的宽度和高度比例。 要使加载的图像适合该区域,缩放以使所有内容都在内部,您可以执行以下操作:

    var scale:Number = Math.min( _holder.width / _loader.content.width,
                            _holder.height / _loader.content.height );
   _loader.content.scaleX = _loader.content.scaleY = scale;

这将确保您可以看到一切。 如果将Math.min更改为Math.max,如果尺寸不匹配,则会得到不同的结果。

 public function loaderComplete(event:Event):void
   { 
  var content:MovieClip = MovieClip(event.currentTarget.content );

  //the dimensions of the external SWF
  var _width:int = content.width;
  var _height:int = content.height;

  // you have several options here , assuming you have a container Sprite
  // you can directly set to the dimensions of your container, if any
  if( container.width < _width )
      _width = container.width // and do the same for height

  // or you could scale your content to fit , here's a simple version
  // but you can check the height too or keep checking both value
  // until it fits
  if( container.width < _width ) 
  { 
      var scale:Number = container.width / _width;
      content.scaleX = content.scaleY = scale;
  }

  }

这个答案更好地理解了swati singh给出的先前代码。请参阅此链接如何调整外部SWF的大小以适应容器? 谢谢大家

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM