I\'m trying to get away from using code on the main timeline but I\'m struggling to understand how .as files and .fla files interact. For example, I\'m trying to figure out how
Parameters of simple types are passed by value, so in order to return a changed String
, make your public function return String
:
public function convertToDecimal(stringParmter:String):String {...}
Then, when you come up with a value that you want to be available outside, put a return
statement in your function. In order to capture the value returned from a function, assign it to a variable, the same one that's passed into it can be used.
stringParameter=convertToDecimal(stringParmter);
Also, if your AS3 file contains only the function, you can avoid wrapping it into a class, and declare directly "public function...".
package
{
public function convertToDecimal(stringParmter:String):String
{
var rex:RegExp = /[\s\r\n]+/gim;
var s:String;
s = stringParmter.replace(/^\s+|\s+$/g, '');
s = s.replace(rex,'.');
s = s.replace(/^0+(?!\.|$)/, '');
if ((s == "-----.--") || (s == "0"))
{
s = " 00";
}
return s;
}
}