RussellReal
11-08-2009, 02:21 AM
how would I LOAD an image.. into a movieclip.. then resize the movieclip to the size of the image..
now I know how to put the image inside of the movieclip with addChild(), but then when I try to resize the movieclip to the size of the IMAGE, it changes the size of the image inside the movieclip.. now I know that when a movieclip scales so does everything else.. so my question is.. how to go about modifying this to make it work no matter what
basically I have a editor so to speak and when you drag the blips it will resize it.. but the problem is actually LOADING the image into the movieclip because once it is same width/height as the movieclip (and shows that way on the screen) my script will handle it perfectly. is there a trick to this.. here is the code I've got so far..
function dispatch(e:Event):void {
this.removeChildAt(2);
var l:LoaderInfo = imageLoader.contentLoaderInfo;
var sizes:Array = alter_image_sizes(l.width,l.height,this.parent.par ent.width,this.parent.parent.height);
this.addChildAt(imageLoader,2);
this.width = sizes[0];
this.height = sizes[1];
this.getChildAt(2).width = this.width * this.scaleX;
this.getChildAt(2).height = this.height * this.scaleY;
MovieClip(this.parent).applyBorder();
}
the loader can change so I remove it from the movieclip when the dispatch function gets called, imageLoader is the loader which loads the image.. sizes just returns either max sized resized proportions or regular height of the image.. note "this" or rather the element I'm using is by default 100x100.
also notice I tried using scaleX and scaleY but I've tried it without and still no luck. please help! Thanks <3
now I know how to put the image inside of the movieclip with addChild(), but then when I try to resize the movieclip to the size of the IMAGE, it changes the size of the image inside the movieclip.. now I know that when a movieclip scales so does everything else.. so my question is.. how to go about modifying this to make it work no matter what
basically I have a editor so to speak and when you drag the blips it will resize it.. but the problem is actually LOADING the image into the movieclip because once it is same width/height as the movieclip (and shows that way on the screen) my script will handle it perfectly. is there a trick to this.. here is the code I've got so far..
function dispatch(e:Event):void {
this.removeChildAt(2);
var l:LoaderInfo = imageLoader.contentLoaderInfo;
var sizes:Array = alter_image_sizes(l.width,l.height,this.parent.par ent.width,this.parent.parent.height);
this.addChildAt(imageLoader,2);
this.width = sizes[0];
this.height = sizes[1];
this.getChildAt(2).width = this.width * this.scaleX;
this.getChildAt(2).height = this.height * this.scaleY;
MovieClip(this.parent).applyBorder();
}
the loader can change so I remove it from the movieclip when the dispatch function gets called, imageLoader is the loader which loads the image.. sizes just returns either max sized resized proportions or regular height of the image.. note "this" or rather the element I'm using is by default 100x100.
also notice I tried using scaleX and scaleY but I've tried it without and still no luck. please help! Thanks <3