Search code examples
apache-flexactionscript-3flex4flash

checking uploaded image resolution and details at client side


In flex, what we do, we normally upload the image from flex end and upload it to the server, i want to know, can we do some details checking, like i want to find out the image resolution(on the client side) before it is uploaded to the server,

There are going to be two profits, first the client doesn't need to wait for long to image get uploaded, and in case if finding the image resolution is on the server end, so it willtake time, even the image to be uploaded is not of expected resolution

second, the user interaction & interface with the flex application will be improved,

so, please give some idea to to this sort of checking from the flex end


Solution

  • If you mean the width/height measuring of a bitmap loaded into your flex app, width/height is stored in BitmapData structure http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html

    For Image flex control it can be accessed with the construction:

    // image_control is an instance of mx.controls.Image
    var width:Number = 0;
    var height:Number = 0;
    if (image_control.content is Bitmap)
    {
       height= (image_control.content as Bitmap).bitmapData.width;
       height= (image_control.content as Bitmap).bitmapData.height;
    }