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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:42:10+00:00 2026-05-24T04:42:10+00:00

I tried to make the nearest button to the clicked text input default. For

  • 0

I tried to make the nearest button to the clicked text input default. For this purpose, I wrote the below code.

Firstly, why is my buttonSwitcher function following behind the MouseEvent.CLICK ?
Secondly, Is there better way to do this ?

Thanks in advance

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="addListeners()">
    <mx:Script>
        <![CDATA[

            public function addListeners():void {
                a.addEventListener(MouseEvent.CLICK, buttonSwitcher);
                b.addEventListener(MouseEvent.CLICK, buttonSwitcher);
            }

            public function buttonSwitcher(event:MouseEvent):void {

                form.defaultButton = (((event.currentTarget as TextInput).id == "a") ? aButton : bButton); 

            }
        ]]>
    </mx:Script>

    <mx:Panel>
        <mx:Form id="form">
            <mx:FormItem label="a" direction="horizontal">
                <mx:TextInput id="a" />
                <mx:Button id="aButton" label="aButton" />
            </mx:FormItem>
            <mx:FormItem label="b" direction="horizontal">
                <mx:TextInput id="b" />
                <mx:Button id="bButton" label="bButton" />
            </mx:FormItem>
        </mx:Form>
    </mx:Panel>
</mx:Application>
  • 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-24T04:42:12+00:00Added an answer on May 24, 2026 at 4:42 am

    use ht ecapture phase of the event to change the buttons and maybe use the FocusEvent instead of CLICK, then you also switch buttons when use “tabs” through inputfields:

    private function addListeners():void
    {
        a.addEventListener(FocusEvent.FOCUS_IN, buttonSwitcher, true);
        b.addEventListener(FocusEvent.FOCUS_IN, buttonSwitcher, true);
    }
    
    public function buttonSwitcher(event:FocusEvent):void 
    {
        form.defaultButton = (((event.currentTarget as TextInput).id == "a") ? aButton : bButton); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to make this code perform faster using Parallel.ForEach and ConcurrentBag but it's
I tried to make the button go down with margin, padding, top to be
Code where I tried to make connection: DataSource ds = (DataSource)servlet.getServletContext().getAttribute(dbSource); System.out.println(ds1 : +ds);
I tried to make the title as clear as possible... here is my scenario:
While creating a file synchronization program in C# I tried to make a method
I am tying to make comments in a blog engine XSS-safe. Tried a lot
I've tried scrolling=no and overflow:hidden; Nothing seems to make the vertical scrollbar go away
Tried something like this: HttpApplication app = s as HttpApplication; //s is sender of
I tried scouring the web for help on this issue, but there are so
I recently tried to make a game server controller in Perl, I would like

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.