OK, I've made a modified version more suitable for MXML and would love
to get feedback from everyone. Ideally I would be able to bind a field
or label directly to the formatted output and would not require a
click to 'reset' the field that is bound to the formatted value. How
would I accomplish that? (I tried but was unsuccessful.) Here is the
modified class:
public class QuickDateFormatter extends DateFormatter
{
public var str_dateString:String;
public var str_dateFormat:String;
[Bindable] public var str_formattedDate:String;
public function getFormattedDate():void
{
var f:DateFormatter = new DateFormatter();
f.formatString = str_dateFormat;
str_formattedDate =
f.format(DateFormatter.parseDateString(str_dateString));
}
}
and a sample usage:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:local="*">
<local:QuickDateFormatter id="qdf" str_dateString="{d.text}"
str_dateFormat="{f.text}" />
<mx:Label text="{qdf.str_formattedDate}" x="72" y="168"/>
<mx:TextInput x="72" y="117" width="133" id="d"/>
<mx:TextInput x="222" y="117" width="91" id="f"/>
<mx:Label x="72" y="91" text="Date"/>
<mx:Label x="222" y="91" text="Format"/>
<mx:Button x="341" y="117" label="Go" click="qdf.getFormattedDate();"/>
</mx:Application>
Thanks,
Ben
http://www.returnundefined.com
--- In [email protected], "gotgoose09" <[EMAIL PROTECTED]> wrote:
>
> All you have to do is add public properties like this:
>
> [Bindable]
> public var str_dateFormat:String;
> [Bindable]
> public var str_dateString:String;
> --- In [email protected], "ben.clinkinbeard"
> <ben.clinkinbeard@> wrote:
> >
> > Yea, what I am looking for is some help on what changes would need to
> > be made to the class to allow it to be used in a format similar to
this:
> >
> > <utils:QuickDateFormatter id="qdf" str_dateString="{model.someDate}"
> > str_dateFormat="MM/DD/YY" />
> > <mx:Label text="{qdf}" />
> >
> > Thanks,
> > Ben
> >
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
See what's inside the new Yahoo! Groups email.
http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~->
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/