View Full Version : Urgente Flash + xml


Goncalosmc
16-06-2008, 22:10
Boas amigos e o seguinte eu sou iniciante em flash e tou com um problemao com integração do flash + xml
E o seguinte eu tenho um ficheiro xml que contem dados sobre produtos.Estes sao trnsportados para uma combobox e quando selecionar um produto na combobox aparecerá numa list os varios modelos que existem desse produto
O problema e que quando eu seleciono um produto da list nao aparece os dados desse produto (nome,preço e a imagem)

Por exemplo
na Combobox tenho: Placas graficas
Na list vai aparecer : Radeon,ATI...
E quero que apareca as caracteristicas nas texts (nome,preço) quando selecionar uma marca
Espero nao ter sido confuso.
Desde ja o meu obrigado.

O codigo foi retirado da net eu tentei adaptar as minhas necessidades.

Codigo action/Script

textab = new Array();
base_XML = new XML();
base_XML.onLoad = traiteXML;
base_XML.ignoreWhite=true;
base_XML.load("test.xml");
stop();
function traiteXML (){
textab = base_XML.firstChild.childNodes;

for(i=0; i<textab.length; i++){
_root.liste.addItem(textab[i].attributes.titre,textab[i].attributes.texte);
_root.liste.setChangeHandler("action");
_root.liste.setChangeHandler("lista");
totalitens=base_XML.firstChild.childNodes
[liste.getSelectedIndex()].childNodes;
}
function lista(){
_root.descricao=_root.textab[_root.liste.getSelectedIndex()].childNodes[_root.lista.getSelectedIndex()].attributes.titre;
_root.nom = _root.textab[_root.liste.getSelectedIndex()].childNodes[_root.lista.getSelectedIndex()].attributes.auteur;
_root.numero = _root.textab[_root.liste.getSelectedIndex()].childNodes[_root.lista.getSelectedIndex()].attributes.id;
}
}
function action(){
lista.removeAll()
for(c=0;c<totalitens.length;c++){
lista.addItem(_root.textab[_root.liste.getSelectedIndex()].childNodes[c].attributes.titre)
}
}ficheiro xml

<Liste>
<File id="1" titre="Placas" texte="Placas" auteur="Plcas">
<produto id="2" titre="Placas filho" texte="Placas filho" auteur="Placas filho"/>
<produto id="3" titre="Placas filhofilhofilho" texte="Placas filho filho" auteur="Placas filho"/>
<produto id="4" titre="Placas filhofilhofilhofilho" texte="Placas filho filhofilho" auteur="Placas filho"/>

</File>
<File id="3" titre="Motherboard" texte="Motherboard" auteur="Motherboard">
<a id="4" titre="Motherboard filho" texte="Motherboard filhinho" auteur="Motherboard filhinho"/>
<a id="4" titre="Motherboard filho" texte="Motherboard filhinho" auteur="Motherboard filhinho"/>
</File>
<File id="1" titre="sadsad" texte="Placassss" auteur="d">
<a id="2" titre="Placass" texte="Placass" auteur="Placass"/>
<a id="2" titre="Placass" texte="Placass" auteur="Placass"/>
<a id="2" titre="Placass" texte="Placass" auteur="Placass"/>
<a id="2" titre="Placass" texte="Placass" auteur="Placass"/>
</File>
<File id="1" titre="aaaa" texte="Placassss" auteur="Pfs">
<a id="2" titre="Placass" texte="Placass" auteur="Placass"/>
<a id="2" titre="Placass" texte="Placass" auteur="Placass"/>
</File>
<File id="1" titre="sss" texte="Placassss" auteur="Pg">
<a id="2" titre="Placass" texte="Placass" auteur="Placass"/>
<a id="2" titre="Placass" texte="Placass" auteur="Placass"/>
</File>
</Liste>