When you define a labelFunction for the DateField component to
format date for output you must also define parseFunction. Inverse
function to labelFunction.
For example:
private var dateField : DateField = new DateField();
dateField.labelFunction = myLabelFunction;
dateField.parseFunction = myParseFunction;
private function myLabelFunction( date : Date ) : String {
var df : DateFormatter = new DateFormatter();
df.formatString = "DD/MM/YYYY";
return df.format( date );
}
public function myParseFunction( inputString : String,
formatString : String = "DD/MM/YYYY") : Date {
if (inputString == "") {
return null;
}
var year : Number = Number(inputString.substr(6,4));
var month : Number = Number(inputString.substr(3,2)) - 1;
var day : Number = Number(inputString.substr(0,2));
var date : Date = new Date(year,month,day);
return date;
}
--- In [email protected], poonam vora <[EMAIL PROTECTED]> wrote:
>
> hie misael
> u can try this way.
> i think its a return function mistake
> it has to be String not void.
>
> example
>
> <mx:DateFormatter id="dfconv" formatString="YYYY/MM/DD"/>
> <mx:Script>
> <![CDATA[
> private function formatDate(date:Date):String
> {
> return dfconv.format(date);
> }
> ]]>
> </mx:Script>
>
> instruction:
> You can choose a different name for the function,
> but it must take a single argument of type Date and
> return the date as a String for display in the text field.
>
> bye,,
>
> Misael <[EMAIL PROTECTED]> wrote: Hi,
> I have a dateField on which i want to format the displayed date. I
want to show it like "DD/MM/YYYY". I´m trying to use this function
with a call in the change="formatNasc(DateField
(event.target).selectedDate)" event, but it still displays
in "MM/DD/YYYY" format.
>
> private function formatNasc(date:Date):void{
> var formatter:DateFormatter = new DateFormatter();
> formatter.formatString = "DD/MM/YYYY";
> xClienteDataNasc.text = formatter.format(date);
> }
>
> What´s the point here?
> Regards.
>
>
> --
> Flexcoders Mailing List
> FAQ:
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%
40yahoogroups.com
>
>
>
> SPONSORED LINKS
> Web site
design development Computer
software development Software
design and
development
Macromedia flex
Software development best
practice
>
> ---------------------------------
> YAHOO! GROUPS LINKS
>
>
> Visit your group "flexcoders" on the web.
>
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
>
>
> ---------------------------------
>
>
>
>
>
> ---------------------------------
> Yahoo! India Answers Share what your know-how and wisdom
> Send free SMS to your Friends on Mobile from your Yahoo!
Messenger Download now
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
| Web site design development | Computer software development | Software design and development |
| Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

