开发者

movieclip rescales strangely

var pic0ldr:Loader = new Loader();
var thumb0Req:URLRequest = new URLRequest("0.jpg");
pic0ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, function(evt:Event){onComplete(evt, "stgW","stgH开发者_运维问答")});
pic0ldr.load(thumb0Req);

function onComplete(event:Event,stgW,stgH):void {
this[stgW] = event.target.content.width;
this[stgH] = event.target.content.height;
placeem("stgW","stgH");
}

function placeem(stgW,stgH):void {

leftmask_mc.height = this["stgH"];
leftmask_mc.width = this["stgW"];
pic0ldr.y = -this["stgH"];
pic0ldr.x = -this["stgW"];

trace(leftmask_mc.width,leftmask_mc.height,pic0ldr.height,pic0ldr.width);//500 707 707 500


leftmask_mc.addChild(pic0ldr);  //strange resize

leftmask_mc.height = this["stgH"];//
leftmask_mc.width = this["stgW"]; // normal again, without 569.25 845.55 707 500

trace(leftmask_mc.width,leftmask_mc.height,pic0ldr.height,pic0ldr.width);
}

You may wonder why I need the width and height data to resize my movieclip but I load many pictures and I have to get the max height and width


A bit hard to be sure what your question is, since you don't actually ask one, but I guess the problem is this:

If you set width and height of a MovieClip, like your leftmask_mc, to other proportion than it originally had, it will be distorted. Any child you add to that MovieClip will also be distorted in the same way, since it becomes a part of that MovieClip.

Also, if leftmask_mc is intended to be used as a mask, you probably don't want to add the loaded image as a child of leftmask_mc. If you want leftmask_mc to mask the image, you should instead set the .mask property of the image (or of a DisplayObject containing the image) to leftmask_mc.


Really have no idea what you are asking in your question.
But I will tell you, your code sample is horrendous, you are all over the place with functions and even using nameless functions.

leftmask_mc.height = this["stgH"];
leftmask_mc.width = this["stgW"];
pic0ldr.y = -this["stgH"];
pic0ldr.x = -this["stgW"];

trace(leftmask_mc.width,leftmask_mc.height,pic0ldr.height,pic0ldr.width);//500 707 707 500

// this is your problem when you pic0ldr, pic0ldr is is set to a NEGATIVE X and Y Which will cause leftmask to resize that amount
leftmask_mc.addChild(pic0ldr);  //strange resize

Again you need to reword your question and rework your code so it is legible to a point where we can understand it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜