A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Return Array From An Event AS3

Threaded View

  1. #1
    Junior Member
    Join Date
    Sep 2004
    Posts
    2

    Return Array From An Event AS3

    I got a question that is driving me crazy. I have a DIRECTORY_LISTING event, that is executed with the files in a directory. This code is n a method o a class that only does the return a array with this informations (the code is above). How can I add a return of this array on a method in the DocumentClass that invoke and receive this value?

    Code:
    //Lista arquivos
    public function listaArquivos(diretorio:File, nome_arquivo:String, lista_molduras:Array, index:int):Array{
      //Tenta fazer tudo isso
      try{
        //Seta o diretoório de molduras
        var directory = diretorio;
        directory.getDirectoryListingAsync();
        directory.addEventListener(FileListEvent.DIRECTORY _LISTING, listaHandler);
    
        //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[i].name;
            var nome_array:Array = new Array();
            nome_array = nome.split("_");
            //Formata para ordenar
            arquivos_animacao.push ({nome:contents[i].name, tamanho:contents[i].size, ordem:nome_array[0]});
          }
          //Ordena para a ordem de númeração
          arquivos_animacao.sortOn("ordem", Array.NUMERIC);
          lista_molduras[index] = arquivos_animacao;
        }
      }catch(erro:ReferenceError){
      }
      return lista_molduras;
    }
    Last edited by 5TonsOfFlax; 06-15-2011 at 09:15 AM. Reason: formatting

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center