 					}
 					catch (e:Error)
 					{
-						// will get SyntaxError if script uses a return statement outside a function
+						// will get SyntaxError if script uses a return statement outside a function like "return 2+2"
 						if (e is SyntaxError)
 						{
 							args.pop();

		{
			try
			{
				var isFunc:Boolean = unnamedFunctionRegExp.test(script);
				if (isFunc)
					script = "(" + StandardLib.trim(script) + ")";
				// first try wrapping the script in "return eval(script)"
				var args:Array = (paramNames || []).concat("return eval(" + JSON.stringify(script) + ");");
				var func:Function = Function['apply'](null, args);
				if (isFunc)
					func = func();
				return function():* {

								if (e2 is SyntaxError)
									func = Function['apply']();
								
								return handleScriptError(e2, 'compiling', script, paramNames, errorHandler);
							}
							
							try
							{
								return func.apply(this, arguments);
							}
							catch (e3:Error)
							{
								return handleScriptError(e3, 'evaluating', script, paramNames, errorHandler);
							}
						}
						return handleScriptError(e, 'evaluating', script, paramNames, errorHandler);
					}
				};
			}
			catch (e:Error)
			{
				// always throw when initial compile fails
				handleScriptError(e, 'compiling', script, paramNames, errorHandler);
				throw e;
			}
		}
		
		private static function handleScriptError(e:Error, doingWhat:String, script:String, paramNames:Array, errorHandler:Function):*
		{
			script = StandardLib.replace(script, '\n','\n\t');
			script = StandardLib.trim(script);
			var paramsStr:String = paramNames && paramNames.length ? ' with params (' + paramNames.join(', ') + ')' : '';
			e.message = StandardLib.substitute('Error {0} script{1}:\n\t{2}\n{3}', doingWhat, paramsStr, script, e.message);
			if (errorHandler != null)
				return errorHandler(e);
			else
				throw e;
		}
		
		/**
