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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:44:12+00:00 2026-06-05T20:44:12+00:00

Below is a self-contained application you can run. It simply displays a spark combo

  • 0

Below is a self-contained application you can run. It simply displays a spark combo box with a reset button. If you select an entry, such as “Red”, then click on the “Reset Combo Box” button, the selected entry in the combo box is cleared. However, it should also remove any error message for the combo box, but this error message is not getting removed. A second click of the Reset button will remove the error.

Anyone know a solution that doesn’t require a second click on the Reset button?

<?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" minWidth="955" minHeight="600">
<fx:Declarations>
    <mx:NumberValidator id="valCB" source="{myCB}" 
                        property="selectedIndex" minValue="0" 
                        lowerThanMinError="This field is required."/>
</fx:Declarations>

<fx:Script>
    <![CDATA[   
        import mx.events.ValidationResultEvent;
        import mx.validators.*;

        private function resetCB():void {
            valCB.enabled=false;   <!-- disable validator -->
            myCB.selectedIndex=-1; <!-- reset selected entry -->
            valCB.enabled=true;    <!-- enable validator -->
            myCB.errorString="";   <!-- clear error msg -->
        }   
    ]]>
</fx:Script>

<s:Form id="myForm">                
    <s:layout>
        <s:FormLayout gap="-5"/>
    </s:layout>
    <s:FormItem label="Select a Color"  required="true">
        <s:ComboBox id="myCB" width="140" prompt="Select a Color"> 
            <s:dataProvider>
                <mx:ArrayList>
                    <fx:String>Red</fx:String>
                    <fx:String>Blue</fx:String>
                    <fx:String>Green</fx:String>
                </mx:ArrayList>
            </s:dataProvider>
        </s:ComboBox>
    </s:FormItem>
</s:Form>
<s:Button label="Reset Combo Box" x="60" y="60" click="resetCB()"/>
</s: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-06-05T20:44:13+00:00Added an answer on June 5, 2026 at 8:44 pm

    This seems like a bug on Adobe’s part to me, though I’m not sure if the intended behaviour would be for it to work on the first click, or to not work at all. You’re setting the selectedIndex to a value not allowed by your validator, turning the validator on and expecting it not to validate. I’m not sure what I would expect to happen.

    It might be better to just disable the validator in the click event, and re-enable it in a change event. Remove valCB.enabled=true; from the reset function (and myCB.value = -1;, since the value will already be -1):

    private function resetCB():void {
        valCB.enabled=false;   <!-- disable validator -->
        myCB.errorString="";   <!-- clear error msg -->
    } 
    

    and give the ComboBox a change event:

    <s:ComboBox id="myCB" width="140" prompt="Select a Color" change="enableValidate()">
    

    And then enable the validator in that event:

    protected function enableValidate():void
    {
        valCB.enabled=true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a self-contained application you can run that illustrates my question. When using a
(the example code below is self-contained and runnable, you can try it, it won't
For this code example below, usually I would use [self fall]; instead of the
I have the code below. I'm wondering that does the self.value and _value have
BACKGROUND: My goal is to code a TestNG-Selenium system that runs self-contained (no strings
Possible Duplicate: RegEx match open tags except XHTML self-contained tags How to remove single
I have little problem in my iPhone application code but can not identify. please
I run the simulator on a very simple app- a navigation controller contained in
ive got a view based application containg a button clicking the button takes you
I'm writing a jQuery extension contained in a self executing function: (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.