From e140e9bb3a25618b01d209f84e2e925cbe67655c Mon Sep 17 00:00:00 2001 From: mboudreau Date: Thu, 12 May 2011 15:36:43 -0700 Subject: [PATCH] Adding own 'substitute' method (for variable injections) to replace the one in mx.utils.StringUtil. --- src/com/adobe/utils/StringUtil.as | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/com/adobe/utils/StringUtil.as b/src/com/adobe/utils/StringUtil.as index d7e98ed..bec3319 100644 --- a/src/com/adobe/utils/StringUtil.as +++ b/src/com/adobe/utils/StringUtil.as @@ -42,7 +42,34 @@ package com.adobe.utils */ public class StringUtil { - + /** + * Variable string injection. Replaces all instances of '{n}' with + * the parameter equivalent where 'n' equals a number. + * + * @param string The first string to injects variables into. + * + * @param ... The unlimited number of variables to be injected. + * + * @returns A string with the variables injected + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function substitute(string:String, ...params:Array):String + { + // Check to see if there's something to inject + if(params && params.length > 0) + { + // Iterate through array, try to inject vars in string + for(var i:uint = 0, len:uint = params.length; i