tiago.iju 0 Denunciar post Postado Agosto 30, 2006 Boa tarde gente boa! Seguinte, eu quero fazer um sistema de news em Flash usando XML. Basicamente, a estrutura do meu xml é assim: <?xml version="1.0" encoding="utf-8"?><news titulo="Notícia 1" data="30/08/06" texto="Texto referente à notícia 1" /><news titulo="Notícia 2" data="01/09/06" texto="Texto referente à notícia 2" /><news titulo="Notícia 3" data="12/09/06" texto="Texto referente à notícia 3" /> Eu gostaria de criar um campo de texto dinâmico com as notícias corridas, dando uma linha de espaço entre cada uma. Não quero menu nem nada... Só exibi-las... Usei, em AS, um código assim: texto.htmlText ="Carregando as notícias..."texto.html = true;var news:XML = new XML();news.ignoreWhite = true;_global.total = this.childNodes.length;news.onLoad = function(){ texto.htmlText = "<b>"+this.childNodes[0].attributes.data+"</b><br>"+this.childNodes[0].attributes.texto+"" }news.load('news.xml'); Dessa forma, ele lê apenas o primeiro item [0]. Se eu for mudando os número, vai mudando as notícias. Então usei um for(a=0; a<total; a++) ali na função, mas não funcionou mais... Alguém pode me ajudar? Compartilhar este post Link para o post Compartilhar em outros sites
Antoniosp 2 Denunciar post Postado Agosto 30, 2006 Tiago, posta só o seu 'for' inteiro como você fez, por favor? Acredito que será mais fácil você entender o engano, beleza? ;)Flw Compartilhar este post Link para o post Compartilhar em outros sites
tiago.iju 0 Denunciar post Postado Agosto 30, 2006 botei assim: texto.htmlText = "Carregando as notícias...";texto.html = true;var news:XML = new XML();news.ignoreWhite = true;_global.total = this.childNodes.length;news.onLoad = function(){ for(i=0; i<total; i++){ texto.htmlText = "<b>"+this.childNodes[i].attributes.data+"</b><br>"+this.childNodes[i].attributes.texto+"" }}news.load('news.xml'); Compartilhar este post Link para o post Compartilhar em outros sites
Eder Fortunato 15 Denunciar post Postado Agosto 31, 2006 cara naum entendi pq você colocou isso fora do onLoad_global.total = this.childNodes.length;isso deveria ficar dentro da on Load do XML, se ele naum carregou como vai saber o total? Compartilhar este post Link para o post Compartilhar em outros sites
tiago.iju 0 Denunciar post Postado Agosto 31, 2006 Ok, vlw pela dica... Mas continua dando erro, mesmo com '_global.total = this.childNodes.length;' dentro da função... Ele lê apenas 1 notícia...Como faço pra ele ir lendo as outras? Compartilhar este post Link para o post Compartilhar em outros sites
Eder Fortunato 15 Denunciar post Postado Agosto 31, 2006 cara eu fiz o teste aqui e foi sim, ele lê todos var news:XML = new XML();news.ignoreWhite = true;_global.total = this.childNodes.length;news.onLoad = function(){ _global.total = this.childNodes.length; for(i=0; i<total; i++){ trace( "<b>"+this.childNodes[i].attributes.data+"</b><br>"+this.childNodes[i].attributes.texto+"") }}news.load('news.xml'); vê se ele naum ta sobrescrevendo na caixa de texto Compartilhar este post Link para o post Compartilhar em outros sites
tiago.iju 0 Denunciar post Postado Agosto 31, 2006 var news:XML = new XML();news.ignoreWhite = true;news.onLoad = function(){ _global.total = this.childNodes.length; for(i=0; i<total; i++){ texto.htmlText = "<b>"+this.childNodes[i].attributes.titulo+"</b><br>"+this.childNodes[i].attributes.texto+"<br>" }}news.load('news.xml'); AGORA DEU CERTINHO! Faltava um '+=' depois de 'texto.htmlText' pra que ele fosse adicionando cada linha do for... Antes, com =, ele associava todas as respostas na mesma... Compartilhar este post Link para o post Compartilhar em outros sites