views:

2136

answers:

2

I cannot find any way to clear a DateField control programmatically after either a user has selected a date, or after I set myDateField.selectedDate via code.

Documentation only states how to clear it if a user selects the date again.

But doing myDateField.selectedDate = myDateField.selectedDate doesn't work

I have tried all the obvious, myDateField.selectedDate = null, myDateField.text = "" - but nothing seems to be doing the trick.

Does anyone have any ideas?

+3  A: 

I made a minimal test example:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
    <mx:Script>
     <![CDATA[
     private function clearDate():void {
      testField.selectedDate = null;
     }
     ]]>
    </mx:Script>
    <mx:DateField id="testField"/>
    <mx:Button label="Clear" click="clearDate();"/>
</mx:Application>

and it seems to work fine. Are you sure there isn't some baffling bug in your code?

(This is with FB 3.2 here, by the way, in case it is a version issue.)

willw
A: 

It works on FB2 too.

tousdan