xml problems


hello!, been working mini-form, have 3 combobox , 1 textbox components.
the basic idea basica load country series, each 1 of have state , each state have city, every city has price.

 

right working 3  comboboxes no textbox whit price.

 

the structure of xml is:
------------------------------------------------------------------------------------------ -----
<countries>
<country label="country-one">
<state  label="state-a">
<city label="city-1a"  price="123"/>
<city label="city-2a" price="456"/>
</state>
<state  label=" state-b ">
<city label="city-1b" price  ="789"/>
</state>
<state label=" state-c  ">
<city label="city-1c" price="567"/>
</state>
</country>

 

<country  label="country-two">
<state label=" state-1">
<city  label="city-a1 " price="654"/>
<city label="city-a2 "  price="321"/>
</state>
<state label=" state-2">
<city label="city-b1" price="765"/>
<city  label=" city-b2 " price="432"/>
</state>
</country>
</countries>
------------------------------------------------------------------------------------------ ---------------
****************************************************************************************** ***************

and as2 code been use is:
****************************************************************************************** ****************
------------------------------------------------------------------------------------------ ------------------

var la_lista:xml = new xml();
la_lista.ignorewhite = true;
la_lista.onload = function(ok){
if(ok) show_countries(this.firstchild.childnodes);
}
la_lista.load('la_lista.xml');
//------------------------------------------------------------------------------->
var show_countries:function = function(list_countries:array):void{
var myprovider:array = new array();
combo1.dataprovider = myprovider;
myprovider.additem({label:'- country -',data:'cone'});
for(n=0;n<list_countries.length;n++){
myprovider.additem({label:list_countries[n].attributes['label'],data:n});
}
}
//---------------------------------------------------------------------------------------- --------------->
var show_states:function = function(position_country:number):void{
var list_states:array = la_lista.firstchild.childnodes[position_country].childnodes;
var myprovider:array = new array();
combo2.dataprovider = myprovider;
myprovider.additem({label:'- state -',data:'ctwo'});
for(n=0;n<list_states.length;n++){
myprovider.additem({label:list_states[n].attributes['label'],data:n});
}
}
//---------------------------------------------------------------------------------------- --->
var show_cities:function = function(position_country:number,position_state:number):void{
var list_cities:array = la_lista.firstchild.childnodes[position_country].childnodes[position_state].childnodes;
var myprovider:array = new array();
combo3.dataprovider = myprovider;
myprovider.additem({label:'- city -',data:'cthree'});
for(n=0;n<list_cities.length;n++){
myprovider.additem({label:list_cities[n].attributes['label'],data:n});
}


}

 

//---------------------------------------------------------------------------------------- --------->
var countrywasselected:object = new object();
countrywasselected.change = function(referencia){
price.removeall();
combo2.removeall();
combo3.removeall();
if(referencia.target.value != '') show_states(referencia.target.value);
}

 


var statewasselected:object = new object();
statewasselected.change = function(referencia){
price.removeall();
combo3.removeall();
if(referencia.target.value != '') show_cities(combo1.value,referencia.target.value);
}

 


var citywasselected:object = new object();
citywasselected.change = function(referencia){
if(referencia.target.value != '') show_price(combo2.value,referencia.target.value);
}

 


combo1.addeventlistener('change',countrywasselected);
combo2.addeventlistener('change',statewasselected);
combo3.addeventlistener('change',citywasselected);
combo3.dataprovider = midataprovider;

 


stop();
------------------------------------------------------------------------------------------ -----------------------------------------------

 

i try follow same structure to  load price in text box doesn´t work, notice was  not void should use string.

then  try  change , use similar line:

 

var show_price:function =   function(label_country:string,label_state:string,label_city:string):string{

 

but doesn´t work, gave me error.

i looking load price data on textbox,  can do? confused.., what´s wrong? suggest me do?

 

thanks.

where trying parse price?



More discussions in ActionScript 1 and 2


adobe

Comments

Popular posts from this blog

Joomla site hacked, cant see front and - Joomla! Forum - community, help and support

Christian Home School Programs - Joomla! Forum - community, help and support

Trouble with PF_OutFlag_I_USE_AUDIO and PF_CHECKOUT_LAYER_AUDIO