Thanks gotgoose, I actually realized a lot of that a while after my post and hadn't gotten a chance to update this thread. Thanks for pointing me to that section in the help though, there is some good info there. Upon further review, you can basically do what I was attempting with the built-in DateFormatter.
<mx:DateFormatter id="df" formatString="MM-DD-YYYY" /> <mx:TextInput id="t" /> <mx:Label id="out" text="{df.format(t.text)}"/> My initial purpose was to create a shorter way of formatting dates in AS, which I accomplished and can use like this: QuickDateFormatter.format(myUnformattedString, "MM/DD/YYYY"); Applying it to MXML just sounded like a good learning exercise. I guess a little more research would've helped. :) Thanks for your help. Ben http://www.returnundefined.com/ --- In flexcoders@yahoogroups.com, "gotgoose09" <[EMAIL PROTECTED]> wrote: > > First of all, I would read Creating and Extending Flex 2 Components > > Creating Nonvisual Flex Components > Creating Custom Formatters > > Creating a custom formatter in the documentation. > > The documentation for DateFormatter says that it has a formatString > variable, so you can get rid of str_dateFormat and just use formatString > on your tag. Also, the correct function to override in your custom > formatter is format() so you can replace getFormattedDate() with: > > override public function format(value:Object):String > { > return super.format(value); > } > > Then, you can add this public getter function to bind your > str_formattedDate. > > public function get formattedDate():String > { > return format(str_dateString); > } > > Then, change {qdf.str_formattedDate} to {qdf.formattedDate}. I believe > this should work, report back if you encounter any problems. > --- In flexcoders@yahoogroups.com, "ben.clinkinbeard" > <ben.clinkinbeard@> wrote: > > > > 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 flexcoders@yahoogroups.com, "gotgoose09" thegoosmans@ 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 flexcoders@yahoogroups.com, "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 --------------------~--> Check out the new improvements in Yahoo! Groups email. http://us.click.yahoo.com/7EuRwD/fOaOAA/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/