From: Matt Boles
[mailto:[EMAIL PROTECTED]
Sent: 29 March 2004 13:57
To: 'flexcoders@yahoogroups.com'
Subject: [flexcoders]
CurrencyFormatter in ActionScript
I am using a CurrencyFormatter class
in an ActionScript controller. It works fine if I first declare the
object as an Object, then as a CurrencyFormatter:
class P4_6Controllerb
{
// properties
public var exampleView:Object;
private var myFormatter:Object;
// constructor
public function P4_6Controllerb()
{
init();
}
// methods
private function init():Void
{
myFormatter=new mx.formatters.CurrencyFormatter();
myFormatter.precision=2;
myFormatter.currencySymbol="$";
myFormatter.alignSymbol="left";
}
public function fillLabel():Void
{
exampleView.testLabel.text = myFormatter.format(exampleView.testLabel.text);
}
}
But, if I try to declare the object
as a CurrencyFormatter the controller compiles fine, but no longer works. The
text in the Label just disappears when the format method is used:
class P4_6Controllerb
{
// properties
public var exampleView:Object;
private var myFormatter:mx.formatters.CurrencyFormatter;
// constructor
public function P4_6Controllerb()
{
init();
}
// methods
private function init():Void
{
myFormatter.precision=2;
myFormatter.currencySymbol="$";
myFormatter.alignSymbol="left";
}
public function fillLabel():Void
{
exampleView.testLabel.text = myFormatter.format(exampleView.testLabel.text);
}
}
Any hints??
Thanks-
Matt
Matthew S. Boles
Principal Instructor
Macromedia
[EMAIL PROTECTED]