Skip to main content
Participant
September 19, 2011
Question

Resize Image before Uplaod In flash AS3 using AJAX

  • September 19, 2011
  • 2 replies
  • 1077 views

I want make a image up-loader in flash.i will call to Ajax to upload image, AJAX check for flash re sizer and it re size image using flash re sizer and upload on sever.please any body can help me how i can re size image in flash before upload on server.

This topic has been closed for replies.

2 replies

September 20, 2011

You can resize some bitmap, or movieClip, etc. to a new size by making a new bitmapData at the desired size and drawing the source into the new bitmapData. When doing the draw use a Matrix to accomplish the scaling. Something like so:

var newBitmapData:BitmapData = new BitmapData(320, 240);

var m:Matrix = new Matrix();

m.scale(newBitmapData.width / originalBitmapData.width, newBitmapData.height / originalBitmapData.height);

newBitmapData.draw(originalBitmapData, m);

Kenneth Kawamoto
Community Expert
Community Expert
September 20, 2011

Resizing the image is done by changing the width and height of the Bitmap. You'd then convert that to a BitmapData, then convert that to a JPEG, then upload that to a script (PHP etc).

--

Kenneth Kawamoto

http://www.materiaprima.co.uk/