views:

45

answers:

2

I'm have an issue loading URL variables into Flash where the variables are loading in random order each time the SWF is loaded.

The way the variables are:

var1=value1&var2=value2&var3=value3

but because it's loaded in a random order, the first variable will sometimes get omitted because of the way the & are placed.

Here's the AS I'm using:

loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(new URLRequest(MainURL+"/product_lines.php?product_category_id=2"));
loader.addEventListener(Event.COMPLETE, varsLoaded);

Any ideas (besides having a dummy variable at the start)?

A: 

From the looks of it here you already have product_category_id=2 isn't that enough and for each variable you just put & in front? Or is that one dynamic also?

Edit: this was suppose to be a comment.

Viper_Sb
A: 

if i were you i'd extracted the name-value pairs into an array:

var pairs:Array = 'var1=value1&var2=value2&var3=value3'.split('&');

and pack the result into an object:

var result:Object = new Object();
for(var i: int = 0; i < pairs.length; i++){
    result[pairs[i].split('=')[0]] = pairs[i].split('=')[1];
}
www0z0k
or you don't know variables names?
www0z0k
using the example above, it already gets loaded into a variable like this: "loader.data.var1"
adamzwakk