Comunidad de diseño web y desarrollo en internet online

Problema con elementos del array

Citar            
MensajeEscrito el 18 Mar 2008 02:34 pm
Que tal:

Tengo un problema con este script y no me doy cuenta de la solución.
Lo que hace este script es duplicar un mc que esta en el escenario 9 veces sobre _x, pero lo que no logro es acceder a los elementos del array por separado, o sea qye quiero que cada uno de ellos sea un objeto que se pueda manipular (propiedades etc), yo coloqué el controilador onPress para probar, pero no funciona.
Me podrían dar una mano por favor??

Desde ya mil gracias!

Charlyn
Aqui va el código

Código :

var tiles:Array = new Array(9);
tile = function () {
   tile_width = 34;
   tile_height = 34;
   // 
   x_max = Math.round(Stage.width / tile_width);
   posy = 40;
   for (x = 0; x < x_max; x++) {
      duplicateMovieClip("mc", "bg" + x, this.getNextHighestDepth());
      mc._x = tile_width * x;
      mc._y = posy;
      tiles[x] = eval["bg" + x];
      tiles[x].onPress= function(){
                this._visible=false;
}
   }
};
tile();

Por charlyn

45 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 18 Mar 2008 03:58 pm
Lo que puedes hacer es organizar un poco las líneas y el nombre de la función:

Código :

var tiles:Array = new Array(9);
function tile() {
   tile_width = 34;
   tile_height = 34;
   // 
   x_max = Math.round(Stage.width/tile_width);
   posy = 40;
   for (x=0; x<x_max; x++) {
      duplicateMovieClip("mc", "bg"+x, this.getNextHighestDepth());
      mc._x = tile_width*x;
      mc._y = posy;
      clip = eval("bg"+x);
      clip.onPress = function() {
         this._visible = false;
      };
   }
}
tile();

Saludos!!

Por vcomics

217 de clabLevel



 

Medellin - Colombia

firefox
Citar            
MensajeEscrito el 18 Mar 2008 06:02 pm
Ahh eso esta mejor, pero todavía hay un mc que es el ultimo de la derecha al que no se puede acceder y segun veo, el array funciona asi? me estoy llenando de dudas...
una ayuda por favor!!

gracias

charlyn

Por charlyn

45 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 18 Mar 2008 06:40 pm
Mira esto:

Código :


tiles = new Array();

tile = function () {

   tile_width = 34
   tile_height = 34
   x_max = Math.round(Stage.width / tile_width);
   posy = 40;
   for (i = 0; i < x_max; i++) {
      clip = attachMovie("mc", "bg" + i, _root.getNextHighestDepth());
     clip._x = clip._width * i;
      clip._y = posy;
      tiles.push(clip)
      clip.onPress= function(){
                this._visible=false;
}
   }
};
tile();

Por mcapu

181 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 18 Mar 2008 08:11 pm
Mil gracias MP, fue mucho más que esclarecedor!!!!

charlyn

Por charlyn

45 de clabLevel



Genero:Masculino  

firefox

 

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