Hey all,
Just wondering if anyone more familiar with RegExp can pick what might
be causing the convertToCurrency function below to crash the Flash IDE
and/or browser (no problems if publishing from a straight FlashDevelop
project for some reason). Below is firstly how I call it, and secondly
the class itself:
...
private var _global:Object = GlobalObject.vars;
var currencyFormat:Function = new CustomRegExp().convertToCurrency;
_global.convertToCurrency = currencyFormat;
...
package utils.CustomRegExp
{
public class CustomRegExp extends RegExp
{
public function CustomRegExp()
{
}
public function convertToCurrency ($val:Number):String
{
var pattern:RegExp = /(\d+)(\d{3}(\.|,|$))/gi;
var returnString:String = String($val.toFixed(2));
while (returnString.match(pattern).length != 0)
{
returnString = (returnString.replace(pattern, "$1,$2"));
}
return returnString;
}
}
}
If there is an alternative to the above I would love to see it, but
still curious why the above would cause problems.
Cheers
Adam
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders