0

I want to set width and height of the stage during resize of that swf.. I do it in resize event handling..but doesn't work..any other way to achieve this?

 stage.addEventListener (Event.RESIZE, resizeListener);

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

 }

Thanks

4

3 回答 3

2

by the sounds of it you just need

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

this will keep the content the same size no matter how much you stretch the window

于 2012-04-11T18:50:24.183 回答
1
Updated:

you need is to compare the ratios of the width and height scales of the content and the target. To make the loaded image fit within the area, scaling so that everything is inside you can do something like this:

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

This will make sure that you can see everything. If you change Math.min to Math.max, you will get a different result if the dimensions don't match.

于 2012-04-12T05:03:39.100 回答
0
 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;
  }

  }

This answer gives better understanding of previous code given by swati singh.See this link How to resize an external SWF to fit into a container? Thanks to all

于 2012-04-12T10:46:20.243 回答