The below function would resize any MovieClip placed on the
Stage. The name of the MovieClip in this instance is mascot.
stage.addEventListener(Event.RESIZE, mascot);
function mascot():void
{
// Defining variables
var mc1:MovieClip = this.mascotAni;
var sw:Number = stage.stageWidth;
var sh:Number = stage.stageHeight;
// resizing movieclip
mc1.width = sw/5;
mc1.height = sh/5;
// positioning movieclip
mc1.x = (stage.stageWidth/2)-(mc1.width/2);
mc1.y = (stage.stageHeight/2)-(mc1.height/2);
// keeps the movieclip proportional
mc1.scaleX <= mc1.scaleY ? (mc1.scaleX = mc1.scaleY) : (mc1.scaleY = mc1.scaleX);
// remove the event listener after resizing
stage.removeEventListener(Event.RESIZE, mascot);
}
No comments:
Post a Comment