Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7092455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:18:56+00:00 2026-05-28T08:18:56+00:00

Unable to correctly perform the simplest task – fit image to screen. Pictures loads

  • 0

Unable to correctly perform the simplest task – fit image to screen. Pictures loads from the gallery, it is displays, but having tried many ways to understand that there are some oddities.
I use Flex ViewNavigatorApplication without ActionBar and full screen. Landscape screen orientation. The best option to accommodate the maximum size of image. All images have a size equal proportions of 3264 x 2448.

Do this:

protected var roll:CameraRoll;
protected var loader:Loader;

if(CameraRoll.supportsBrowseForImage && !roll)
{
roll = new CameraRoll();
roll.addEventListener(MediaEvent.SELECT, onSelect);
}

if(roll){
roll.browseForImage();
}

protected function onSelect(e:MediaEvent) : void
{
var data:MediaPromise = e.data;
var promise:MediaPromise = e.data as MediaPromise;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
loader.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, onError);
loader.loadFilePromise(promise);
}
}
private function onImageLoaded(event:Event):void {

var bitmap:Bitmap = Bitmap(event.currentTarget.content);
var ratio:Number = bitmap.width / bitmap.height
trace (bitmap.width + '/' + bitmap.height + ' ratio: ' + ratio);//3264/2448 ratio: 1.3333333333333333
bitmap.width = Capabilities.screenResolutionY;
trace ('screenResolutionX: ' + Capabilities.screenResolutionY);//screenResolutionX: 800
bitmap.height = bitmap.width / ratio;
trace (bitmap.width + '/' + bitmap.height + ' ratio: ' + bitmap.width / bitmap.height);//799.9000000000001/599.95 ratio: 1.3332777731477623
spr.addChild(bitmap); //container
trace (spr.width + '/' + spr.height);//0/0
trace (this.width + '/' + this.height);//533/320 - here is the first - why these data?
trace (stage.width + '/' + stage.height);//1202.8500000000001/918.6500000000001 - 
//here is the second - why these data? 
//On the real phone in debug mode i see that image have about this dimensions, but trace above we see that the dimensions of 800 by 600.
trace (stage.stageWidth + '/' + stage.stageHeight);//800/480 - all OK
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onImageLoaded);
loader.contentLoaderInfo.removeEventListener(ErrorEvent.ERROR, onError);
}

The questions in the comments of traces. I do not understand why this is happening.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:18:57+00:00Added an answer on May 28, 2026 at 8:18 am

    Since you are using Flex, have you tried using the Spark Image component instead of pure actionscript? It has a built in scaling with the scaleMode and fillMode properties. You might try something like this once your image has loaded:

    private function onImageLoaded(event:Event):void {
    
        var bitmap:Bitmap = Bitmap(event.currentTarget.content);
        imageComponent.source = bitmap;
        loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onImageLoaded);
        loader.contentLoaderInfo.removeEventListener(ErrorEvent.ERROR, onError);
    }
    
    <s:Image 
        id="imageComponent"
        fillMode="scale" 
        scaleMode="stretch" 
    />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

date.parse() method of groovy detects date DD and year yyyy correctly but is unable
Why is the compiler unable to infer the correct type for the result from
Error: Unable to read data from the transport connection: A blocking operation was interrupted
I am unable to consume messages sent via ActiveMQ from my Flex client. Sending
My Linked server is setup correctly , I am able to perform below query.
I am unable to get this script to function correctly. When i try to
I am using Visual Studio 2010 with IIS 5.1 but unable to debug my
I'm running PHP 5.3.5-1ubuntu7.2 (with safe_mode = Off ) and I'm unable to correctly
I feel like this one has been asked before, but I'm unable to find
I'm unable to correctly create DOM elements using jQuery (1.3.2): var ev_t; $(#add-event).click(function() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.