无法调整MovieClip ActionScript 2的大小

时间:2011-12-05 21:58:13

标签: image actionscript resize runtime actionscript-2

我创建了一个MovieClip对象并加载了一个图像。但是我想要调整它的大小。我试过_width和_height但它不起作用。 这是代码:

var movieClip:MovieClip;
var pic:String = "http://pro-game.comyr.com/mo.jpg";
movieClip = createEmptyMovieClip("movieClip", 0);
movieClip.loadMovie(pic);

//this doesn't work
movieClip._height = 100;
movieClip._width = 100;

如果有人可以提供帮助,我会很高兴: - )

3 个答案:

答案 0 :(得分:0)

您正在使用操作脚本2.0,请尝试此操作脚本3.0中的代码

var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, ldr_complete);
ldr.load(new URLRequest("http://pro-game.comyr.com/mo.jpg");
function ldr_complete(evt:Event):void
{

   var bmp:Bitmap= ldr.content as Bitmap;
   var img = new Bitmap(bmp.bitmapData);
   img.x =20;
   img.y = 20;
   img.width=500;
   img.height=500;
   addChild(img);
}

答案 1 :(得分:0)

var pic:String = "http://pro-game.comyr.com/mo.jpg";
this.createEmptyMovieClip("movieClip", this.getNextHighestDepth());
movieClip.beginFill(0xFF0000);
movieClip.moveTo(10, 10);
movieClip.lineTo(100, 10);
movieClip.lineTo(100, 100);
movieClip.lineTo(10, 100);
movieClip.lineTo(10, 10);
movieClip.endFill();

this.movieClip.loadMovie(pic);
this.movieClip._width = this.movieClip._height = 20;

尝试设置空movieClip的宽度和高度将始终返回0.

答案 2 :(得分:0)

此代码将在ActionScript 2.0中运行。请尝试任何享受...

var movieClip:MovieClip;
var pic:String = "http://pro-game.comyr.com/mo.jpg";
movieClip = createEmptyMovieClip("movieClip", 0);
movieClip.loadMovie(pic);


movieClip.onLoadComplete = function (targetMC)
{   
   targetMC._parent._width = 100;
   targetMC._parent._height = 100;
}