Array controls XML delievy AS3 -
so, let's have array on flash, like:
var myarray:array = [option2, option3]
and let's have xml file this:
<easformat> <option1> <easimg>img01.jpg</easimg> <easname>carro 01</easname> <easprice>250.000</easprice> </option1> <option2> <easimg>img02.jpg</easimg> <easname>carro 02</easname> <easprice>180.000</easprice> </option2> <option3> <easimg>img03.jpg</easimg> <easname>carro 03</easname> <easprice>80.000</easprice> </option3> <option4> <easimg>img04.jpg</easimg> <easname>carro 04</easname> <easprice>150.000</easprice> </option4> </easformat>
i have xml loaded. want display nodes of xml match array values (options 2 , 3). guys me sort out logic doing this?
thanks lot!
first should change xml structure follows
<easformat> <option> <easimg>img01.jpg</easimg> <easname>carro 01</easname> <easprice>250.000</easprice> </option> <option> <easimg>img02.jpg</easimg> <easname>carro 02</easname> <easprice>180.000</easprice> </option> <option> <easimg>img03.jpg</easimg> <easname>carro 03</easname> <easprice>80.000</easprice> </option> <option> <easimg>img04.jpg</easimg> <easname>carro 04</easname> <easprice>150.000</easprice> </option> </easformat>
and assume search options are
var options:array = ["carro 01", "carro 04"];
now code onloaded xml
var _xml:xml = xml(e.target.data); for(var i:uint = 0; < _xml.option.length(); i++){ easnames.push(_xml.option[i].easname); }
checking weather options in easnames array.
function matchtest():void{ for(var i:uint = 0; < options.length; i++){ for(var j:uint = 0; j < easnames.length; j++){ if(easnames[j] == options[i]){ trace(j); } } } }