Dificuldade em enviar dados do XML pra outras funções
Galera, tenho esse código para paginação de texto
CODE
function setPage(page:Number):Void{
field.scroll = (page - 1) * linesPerPage + 1;
}
**var text = conteudo;**
// Assigns the text field that is on the stage to a local variable
var field = this.textfield;
// Defines whether the textfield is using htmlText
var html = field.html;
// Defines the property that will be used to assign content to the text field
var property = html ? "htmlText" : "text";
// Assign the content to the text field
field[property] = text;
// Extracts the text format and line height properties
var format = field.getNewTextFormat();
var leading = int(format.leading);
var extent = format.getTextExtent(" ");
var ascent = extent.ascent;
var descent = extent.descent;
var lineHeight = ascent + descent + leading;
var linesPerPage = Math.floor((field._height - 4 + leading) / lineHeight);
var lineCount = (field.maxscroll - 1) + linesPerPage;
var pageCount = Math.ceil(lineCount / linesPerPage);
var offset = (linesPerPage * pageCount) - lineCount + 1;
var lineBreak = html ? "<br />" : newline;
for (var i = 0; i < offset; i++)
{
text += lineBreak;
}
field[property] = text;
// Attaches a page select button for each page of text
for (var i = 0; i < pageCount; i++)
{
var pageNumber = this.attachMovie("page number", "page_number" + i, i);
pageNumber._x = field._x + i * 23;
pageNumber._y = field._y + field._height + 10;
pageNumber.label.text = (i + 1);
pageNumber.page = (i + 1);
pageNumber.onRelease = function()
{
setPage(this.page);
}
}
Eu precisava buscar essa variavel conteudo em um arquivo XML.
Estava tentando o seguinte.
CODE
System.useCodepage = true;var arquivo:XML = new XML();
arquivo.load("dados.xml");
arquivo.ignoreWhite = true;
arquivo.onLoad = function() {
var conteudo = this.childNodes[0].childNodes[0].attributes.legenda;
}
Mas não funciona. Se eu der um trace antes de fechar essa última chave, ele busca certinho no XML. Mas em qualquer outro lugar, a variavel não é encontrada. Estou achando que devo colocar todas as demais funções dentro do arquivo.onLoad, mas não sei como fazer isso. Alguém sabe?
Abc
Discussão (2)
Carregando comentários...