QueryParameters AS3 Class

Custom class dependencies: Parameters

QueryParameters is a utility that is meant for working with query strings in Actionscript. It extends the extremely versatile Parameters class, and what it does is fairly simple, yet very useful. It is an object which is automatically converted to a query string. All methods which add/remove properties are overridden to make sure property names and values are always valid Strings ready for use in a URI. All properties may be added like it was a generic object, yet all the extended functionality of the Parameters class is also included like indexing, values, and a length property. In the end, all you need to know is that this class is for working with strings, specifically query strings, and that it does its job well.

Without explaining every single aspect about what you may do with this class, I will instead attempt to give you an example that you may test and compile in your own file to view the output.

Example:

import com.jidd.utils.QueryParameters;

var params:QueryParameters = new QueryParameters();
params.test1 = '';
params.test2 = 'value2';
params.test3 = 'value3';
params.test4 = 'value4';

trace(params.length);

for(var i=0 ; i
 trace('params[' + i + '] = ' + params[i]);
 trace(params.properties[i].name);
 trace(params.properties[i].value);
}

trace('params = ' + params);

var params2:QueryParameters = new QueryParameters();
params2.test2_1 = '';
params2.test2_2 = 'value2_2';
params2.test2_3 = 'value2_3';
params2.test2_4 = 'value2_4';

trace('params2 = ' + params2);

var params3:QueryParameters = new QueryParameters(params, params2);

trace('params3 = ' + params3);

Now here is the source of the class itself. Please make sure to review the Parameters class for additional custom properties and methods also available to this class.

Comment if you have any questions, or suggestions.

Comments

One response to “QueryParameters AS3 Class”

  1. […] Script » URL AS3 ClassPosted by: Jim IsaacsAugust10th2008 Custom class dependancies: QueryParametersThis class is an attempt to have an object that automatically parses any string representing a url. […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.