That error message is generally caused by passing a non valid querystring to an URLVariables object. But you don't need to pass the querystring in most cases. You can just add pairs to the object as regular properties and let it do the encoding and escaping (which is what this class is meant to do).
var vars:URLVariables = new URLVariables();
vars.param1 = "Text to be escaped. Works for non ascii: ñ";
vars.param2 = "http://www.google.com/?q=something&test=1234";
trace(vars.toString());
The trace, of course, is not necessary, it's just so you can see that the encoding worked.