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

  • SEARCH
  • Home
  • 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 5973859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:51:36+00:00 2026-05-22T20:51:36+00:00

So I’m loading a really big pic in this mx:Image manteinAspectRatio enabled with a

  • 0

So I’m loading a really big pic in this mx:Image manteinAspectRatio enabled with a height constraint and as usual it doesn’t work (Flex is definitely not for me):

<?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx">

        <s:Rect top="0" right="0" bottom="0" left="0">
            <s:fill>
                <mx:SolidColor color="#000000"/>
            </s:fill>
        </s:Rect>

        <s:VGroup id="a" top="0" right="0" bottom="0" left="0" horizontalAlign="center" verticalAlign="middle">

            <s:Group id="b">

                <s:Rect id="c" top="0" right="0" bottom="0" left="0" radiusX="10" radiusY="10">
                    <s:fill>
                        <mx:SolidColor color="#cccccc"/>
                    </s:fill>
                </s:Rect>

                <s:VGroup id="d" paddingTop="10" paddingRight="10" paddingBottom="10" paddingLeft="10">

                    <mx:Image id="e" source="big.jpg" maxHeight="300" maintainAspectRatio="true" />

                </s:VGroup>

            </s:Group>

        </s:VGroup>

    </s:Application>

The big.jpg has more width than height so when it’s resized the wrapping containers get the correct new height but they still have the old width.

I’ve tried to call validateNow() on every element, invalidate, callLater(), resize event, compete event… I’m a noob getting tired of AS 3.0

UPDATE:

Reading J_A_X answer I ended up with this:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx">

    <fx:Script>
        <![CDATA[

        import flash.events.Event;
        import mx.controls.Image;

        private function fix(event:Event):void {

            var img:Image = event.target as Image;
            var h:uint = 300;

            img.width *= h / img.height;
            img.height = h;
            img.removeEventListener("updateComplete", fix);

        }

        ]]>
    </fx:Script>

    <s:Rect top="0" right="0" bottom="0" left="0">
        <s:fill>
            <mx:SolidColor color="#000000"/>
        </s:fill>
    </s:Rect>

    <s:VGroup top="0" right="0" bottom="0" left="0" horizontalAlign="center" verticalAlign="middle">

        <s:Group>

            <s:Rect top="0" right="0" bottom="0" left="0" radiusX="10" radiusY="10">
                <s:fill>
                    <mx:SolidColor color="#cccccc"/>
                </s:fill>
            </s:Rect>

            <s:VGroup paddingTop="10" paddingRight="10" paddingBottom="10" paddingLeft="10">

                <mx:Image source="big.jpg" maintainAspectRatio="false" updateComplete="fix(event)" />

            </s:VGroup>

        </s:Group>

    </s:VGroup>

</s:Application>

I hope that helps another one dealing with Flex.

  • 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-22T20:51:37+00:00Added an answer on May 22, 2026 at 8:51 pm

    After looking at Image, it seems that it needs explicit height/width or else it won’t scale down properly. It’s a bit stupid not to scale to the maxHeight, but you could always use Flex 4.5 Image class instead or just create your own to handle max height/width.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I have some data like this: 1 2 3 4 5 9 2 6

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.