Comunidad de diseño web y desarrollo en internet online

duda con un array

Citar            
MensajeEscrito el 14 Nov 2011 02:01 am
Hola, Tengo un pequeño problema tratando de crear un array de 2 dimenciones, y es que lo que quiero hacer es una funcion que pasandole por parametros la altura y la anchura que decees, cree un array de 2 dimenciones con esas medidas pero al tratar de compilarlo me sale el siguiente error:

Código :

[Fault] exception, information=TypeError: Error #1010: Un término no está definido y no tiene propiedades.


y bueno, este es el codigo de la funcion:

Código ActionScript :

public static function createLayer(__width:int, __height:int):Array
      {
         
         var result:Array = new Array();
         
         for (var h:int = 0; h < __height; h++)
         {
            for (var w:int = 0; w < __width; w++)
            {   
               
               result[h][w] = [0xFFFFFF, 1.0];
               
            }
         }
         
         return result;
         
      }


ya he intentado muchas cosas, y espero que me puedan ayudar.
gracias de antemano.

Por swek

23 de clabLevel



 

firefox
Citar            
MensajeEscrito el 14 Nov 2011 04:45 am

Código ActionScript :

function createLayer(__width:int, __height:int):Array {
   var resultado:Array = new Array();

   for (var h:int = 0; h < __height; h++) {
      resultado[h] = new Array();
      for (var w:int = 0; w < __width; w++) {
         resultado[h][w] = h+"_"+w;
      }
   }
   return resultado;
}

var arr:Array =  createLayer(5,5);
trace(arr[1][2]);

Por nasho

Claber

908 de clabLevel

1 tutorial

Genero:Masculino  

Web Developer

chrome

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.