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 6002019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:55:04+00:00 2026-05-23T00:55:04+00:00

I am building a graphic component in MXML that has different states, each state

  • 0

I am building a graphic component in MXML that has different states, each state having its own size.

I have a “normal” state and a “highlighted state”, the highlighted one having a higher height.

On this components I implemented a function to be executed on each mouseOver and mouseOut to change from normal state to highlighted state and back.

My problem is, in the highlighted mode, the mouseout event is triggered according to the size of the normal state.

Here is the code:

<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:mx="library://ns.adobe.com/flex/mx"
       xmlns:controller="com.*"

       mouseOver="mouseOverHandler(event)" mouseOut="mouseOutHandler(event)"
       width="230" height.Playing="40" height.Normal="21" height.Highlighted="40">
<mx:states>
    <mx:State name="Normal" />
    <mx:State name="Playing" />
    <mx:State name="Highlighted" />
</mx:states>
<mx:Button includeIn="Highlighted" left="19" bottom="2" width="15" height="15" />
</mx:Canvas>

Is there something wrong in the way I use mouseOuver and mouseOut ?

Thanks,

Alexandre

  • 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-23T00:55:04+00:00Added an answer on May 23, 2026 at 12:55 am

    I am building a graphic component in
    MXML that has different states, each
    state having its own size.

    You have a misunderstanding of how the Flex Component Architecture works. A component never sizes itself. It is always up to the parent to size it’s children. You can override the measure method to set measuredWidth and measuredHeight; however these are only suggestions provided to the component’s parent. It is up the component to decide whether to accept them or no.

    So, in your example, you can change the height/width of the button (a child); but you cannot change the height/width of the canvas (The component you’re extending) and expect it to stick.

    Without seeing the code that contains this canvas component, it’s hard to say for sure what is going on. But, in this case, you should override the measure method to change the measuredWidth / measuredHeight. Something like this:

    override protected measure():void{
     if(currentState=='Normal'){
      measuredWidth = 0;
      measuredHeight = 0;
     } else {
      measuredWidth = button.width;
      measuredHeight = button.height;
     }
    }
    

    When the state changes, be sure to call the invalidateSize() method. You can do this by listening to the currentStateChange event.

    In theory, that will cause the component to change the measuredWidth/measuredHeight; which will force the parent to also redraw itself, accommodating for the new measuredWidth/measuredHeight.

    MXML masks a lot of these details.

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

Sidebar

Related Questions

the graphic designer of the Android app that I'm currently building has come up
Building a website that has English & Japanese speaking users, with the Japanese users
I'm building a pretty simple player and have a a buffer size set on
I have started building a new component in Delphi 6 Pro. Currently it just
I have had contact with Google Chromium Code and that’s terrific for building applications
Building the same project (without any changes) produces binary different exe-files: some small regions
Building on what has been written in SO question Best Singleton Implementation In Java
building a site using PHP and MySQL that needs to store a lot of
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
I was having some other problems with some ports building for the wrong CPU

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.