[font=Courier New]// This code proportionately resizes an image on the stage. [/font]
[font=Courier New]// It detects the aspect ratio and then increments your image [/font]
[font=Courier New]// a specified increment size. (zoomIncrement)[/font]
[font=Courier New]// The problem is that the image aspect ratio slowly becomes incorrect over time[/font]
[font=Courier New]// thus distorting the image as it becomes resized more and more.[/font]
[font=Courier New]// FLA Download:[/font]
[font=Courier New]// [http://www.aerosdesign.com/fla/ImgResize.fla](http://www.aerosdesign.com/fla/ImgResize.fla)[/font]
[font=Courier New]// TXT Download:[/font]
[font=Courier New]// [http://www.aerosdesign.com/fla/ImgResize.txt](http://www.aerosdesign.com/fla/ImgResize.txt)[/font]
[font=Courier New]// Any help would be appreciated. Email: [/font][email="sciform@gmail.com"][font=Courier New]sciform@gmail.com[/font][/email]
[font=Courier New]stop();[/font]
[font=Courier New]aRatio = m_pic._width / m_pic._height;[/font]
[font=Courier New]aInfo.onRelease = function(){[/font]
[font=Courier New]trace(_root.aRatio);[/font]
[font=Courier New]trace("This is the REAL aspect ratio:" + m_pic._width / m_pic._height);[/font]
[font=Courier New]}[/font]
[font=Courier New]a_plus.onRelease = function(){[/font]
[font=Courier New]currentWidth = m_pic._width; //Current _x value of the image [/font]
[font=Courier New]currentHeight = m_pic._height; //Current _y value of the image[/font]
[font=Courier New]//trace(currentHeight);[/font]
[font=Courier New]//trace(currentWidth);[/font]
[font=Courier New]zoomIncrement = 100;[/font]
[font=Courier New]widthIncrement = zoomIncrement*_root.aRatio;[/font]
[font=Courier New]heightIncrement = zoomIncrement;[/font]
[font=Courier New]//trace(zoomIncrement);[/font]
[font=Courier New]targetWidth = currentWidth + widthIncrement;[/font]
[font=Courier New]targetHeight = currentHeight + heightIncrement;[/font]
[font=Courier New]//trace("This is the current width:" + currentWidth);[/font]
[font=Courier New]//trace("This is the current height:" + currentHeight);[/font]
[font=Courier New]//trace("This is the target width:" + targetWidth);[/font]
[font=Courier New]//trace("This is the target height:"+ targetHeight);[/font]
[font=Courier New]aSpeed = 10; //Speed of the resize: 1 = Instant 30 = Fast[/font]
[font=Courier New]m_pic.onEnterFrame = function(){[/font]
[font=Courier New]m_pic._xscale += (targetWidth - this._width) / aSpeed;[/font]
[font=Courier New]m_pic._yscale += (targetHeight - this._height) / aSpeed;[/font]
[font=Courier New]//m_pic._yscale++;[/font]
[font=Courier New]}[/font]
[font=Courier New]}[/font]
I apologize for the formatting. Can’t seem to get the code formatted correctly on here. For a more readable version, please download the file/txt or check this pastebin post: http://pastebin.sekati.com/?id=ZoomImg@57015-276c30f-t
Best Regards,
Joseph.