Hello folks. I’m a new Flash AS3 job but I have a big problem using some OOP concepts like return from methods, when I needs a Event Listener code. The problem is that the function from Event Listener cannot return a value. How can I work with this issue? This is a code sample that I using on my AIR app. This code I want to re-use in other situations that I want to parse a directory files.
private function initApp():void{
try{
//Seta o diretoório de molduras
var directory = diretorio_mestre.resolvePath("molduras/animacao");
directory.getDirectoryListingAsync();
directory.addEventListener(FileListEvent.DIRECTORY_LISTING, listaHandler);
}catch(erro:ReferenceError){
mostraMensagem("Problemas com a listagem do diretório.", erro.errorID);
}
//Percorre arquivos
function listaHandler(evento):void{
//Contador
var i:int = 0;
//Conteúdo
var contents = evento.files;
for (i = 0; i < contents.length; i++) {
var nome:String = contents*.name;
var nome_array:Array = new Array();
nome_array = nome.split("_");
//Formata para ordenar
arquivos_animacao.push ({nome:contents*.name, tamanho:contents*.size, ordem:nome_array[0]});
}
//Ordena para a ordem de númeração
arquivos_animacao.sortOn("ordem", Array.NUMERIC);
//Continua o processo
//How can I return!?!?!
}
}