[flexcoders] Re: QuickDateFormatter - how can I make it MXML enabled?

2006-07-24 Thread ben.clinkinbeard
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 [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 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 ~-- 
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/
 





[flexcoders] Re: QuickDateFormatter - how can I make it MXML enabled?

2006-07-24 Thread ben.clinkinbeard
OK, I've got it working how I wanted. Would love to hear feedback on
my structure as well as whether or not you find this useful.

Usage:

local:QuickDateFormatter id=qdf date={fieldOne.text}
dateFormat={fieldTwo.text} /
mx:Label text={qdf.output}/

Source class:

package
{
import mx.formatters.DateFormatter;

public class QuickDateFormatter extends DateFormatter
{
private var _str_dateString:String;
private var _str_dateFormat:String;
[Bindable] public var output:String;

public function get date():String
{
return _str_dateString;
}

public function set date(a_str:String):void
{
_str_dateString = a_str;
reformat();
}

public function get dateFormat():String
{
return _str_dateFormat;
}

public function set dateFormat(a_str:String):void
{
_str_dateFormat = a_str;
reformat();
}

private function reformat():void
{
var f:DateFormatter = new DateFormatter();
f.formatString = _str_dateFormat;
output =
f.format(DateFormatter.parseDateString(_str_dateString));
}
}
}

Let me know what you think!
Ben
http://www.returnundefined.com/






--
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/
 





[flexcoders] Re: QuickDateFormatter - how can I make it MXML enabled?

2006-07-24 Thread gotgoose09
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
[EMAIL PROTECTED] 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 ~-- 
Something is new at Yahoo! Groups.  Check out the enhanced email design.
http://us.click.yahoo.com/SISQkA/gOaOAA/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/
 




[flexcoders] Re: QuickDateFormatter - how can I make it MXML enabled?

2006-07-24 Thread ben.clinkinbeard
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- /
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/);

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/
 




[flexcoders] Re: QuickDateFormatter - how can I make it MXML enabled?

2006-07-23 Thread gotgoose09
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
[EMAIL PROTECTED] 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 ~-- 
Something is new at Yahoo! Groups.  Check out the enhanced email design.
http://us.click.yahoo.com/SISQkA/gOaOAA/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/
 





[flexcoders] Re: QuickDateFormatter - how can I make it MXML enabled?

2006-07-21 Thread ben.clinkinbeard
Sorry, it attached my comma to the link. Should be
http://www.returnundefined.com/2006/07/quickdateformatter-efficient-date-formatting-in-as3/

Thanks,
Ben





 Yahoo! Groups Sponsor ~-- 
Great things are happening at Yahoo! Groups.  See the new email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/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/
 





[flexcoders] Re: QuickDateFormatter - how can I make it MXML enabled?

2006-07-21 Thread gotgoose09



All you have to do is:In your application mxml file, add this attribute to the Application tag: xmlns:mycode="com.fmr.utils"Then you can add your formatter with this code:mycode:QuickDateFormatter /You use it by adding id="myQuickDateFormatter" to the tag. An alternative is to put this code in mx:Script tags:import com.fmr.utils;QuickDateFormatter.format();I have a feeling you want something more than this. Feel free to ask again.--- In flexcoders@yahoogroups.com, "ben.clinkinbeard" [EMAIL PROTECTED] wrote: Hello all, I have created and documented a class that greatly simplifies the process of converting a date string to an alternately formatted date string. The current incarnation is described here: http://www.returnundefined.com/2006/07/quickdateformatter-efficient-date-formatting-in-as3/, but I am wondering how I would go about making a version that is able to be used in MXML. I know it would involve the creation of some public properties but beyond that I am pretty clueless. Can someone point me in the right direction?  Thanks, Ben


__._,_.___





--
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.



  






__,_._,___



[flexcoders] Re: QuickDateFormatter - how can I make it MXML enabled?

2006-07-21 Thread ben.clinkinbeard
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 ~-- 
Something is new at Yahoo! Groups.  Check out the enhanced email design.
http://us.click.yahoo.com/SISQkA/gOaOAA/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/