Comunidad de diseño web y desarrollo en internet online

AS3 error 2006

Citar            
MensajeEscrito el 13 Oct 2010 08:28 pm
Tengo una galeria de fotos!, la misma esta compuesta por varios thumbnails que funcionan como botones, para llamar las imagenes externas, y ser proyectadas en un movieclip vacio.

EL PROBLEMA CUAL ES?, el problema es que el campo de texto dinamico con instancia "caption_txt" se queda pegado en el primer titulo, y no cambia a los otros titulos, OJOOO he puesto solo 2 titulos aca "blablabla" y "bleebleeblee"..

no se si tiene que ver, pero me tira este error cada vez que hago click en un thumbnail (boton)
RangeError: Error #2006: El índice proporcionado está fuera de los límites.
at flash.display::DisplayObjectContainer/removeChildAt()
at teatro_fla::WholeGallerye1e1_1/thumb5click()

:(
el codigo que hace funcionar todo es el siguiente codigo:


Código ActionScript :

// Set the name of the external folder your big pics and thumbs are in
var galleryFolder:String = "gallery_2";
/////////////////////////////////////////////////////////////////////////////////////////
// Thumbs Setup, Create loader instances for each thumb
var pic1ldr:Loader = new Loader();
var pic2ldr:Loader = new Loader();
var pic3ldr:Loader = new Loader();
var pic4ldr:Loader = new Loader();
var pic5ldr:Loader = new Loader();
var pic6ldr:Loader = new Loader();
var pic7ldr:Loader = new Loader();
var pic8ldr:Loader = new Loader();
var pic9ldr:Loader = new Loader();
var pic10ldr:Loader = new Loader();
var pic11ldr:Loader = new Loader();
var pic12ldr:Loader = new Loader();
var pic13ldr:Loader = new Loader();
var pic14ldr:Loader = new Loader();
var pic15ldr:Loader = new Loader();
var pic16ldr:Loader = new Loader();
var pic17ldr:Loader = new Loader();
// Set the URLRequest for each little thumbnail, notice how we reference "galleryFolder"
var thumb1Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00001.jpg");
var thumb2Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00002.jpg");
var thumb3Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00003.jpg");
var thumb4Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00004.jpg");
var thumb5Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00005.jpg");
var thumb6Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00006.jpg");
var thumb7Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00007.jpg");
var thumb8Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00008.jpg");
var thumb9Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00009.jpg");
var thumb10Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00010.jpg");
var thumb11Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00011.jpg");
var thumb12Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00012.jpg");
var thumb13Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00013.jpg");
var thumb14Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00014.jpg");
var thumb15Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00015.jpg");
var thumb16Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00016.jpg");
var thumb17Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Images00017.jpg");
// Load each URLRequested thumb image into its pic loader
pic1ldr.load(thumb1Req);
pic2ldr.load(thumb2Req);
pic3ldr.load(thumb3Req);
pic4ldr.load(thumb4Req);
pic5ldr.load(thumb5Req);
pic6ldr.load(thumb6Req);
pic7ldr.load(thumb7Req);
pic8ldr.load(thumb8Req);
pic9ldr.load(thumb9Req);
pic10ldr.load(thumb10Req);
pic11ldr.load(thumb11Req);
pic12ldr.load(thumb12Req);
pic13ldr.load(thumb13Req);
pic14ldr.load(thumb14Req);
pic15ldr.load(thumb15Req);
pic16ldr.load(thumb16Req);
pic17ldr.load(thumb17Req);
// Then add the above to the stage movieclips waiting there to finally display thumbs
// These become your buttons, we code them out now below to make them full fledged buttons
thumbLoader1.addChild(pic1ldr);
thumbLoader2.addChild(pic2ldr);
thumbLoader3.addChild(pic3ldr);
thumbLoader4.addChild(pic4ldr);
thumbLoader5.addChild(pic5ldr);
thumbLoader6.addChild(pic6ldr);
thumbLoader7.addChild(pic7ldr);
thumbLoader8.addChild(pic8ldr);
thumbLoader9.addChild(pic9ldr);
thumbLoader10.addChild(pic10ldr);
thumbLoader11.addChild(pic11ldr);
thumbLoader12.addChild(pic12ldr);
thumbLoader13.addChild(pic13ldr);
thumbLoader14.addChild(pic14ldr);
thumbLoader15.addChild(pic15ldr);
thumbLoader16.addChild(pic16ldr);
thumbLoader17.addChild(pic17ldr);
// Set each button to show mouse hand pointer on ROLL_OVER like it should
thumbLoader1.buttonMode = true;
thumbLoader2.buttonMode = true;
thumbLoader3.buttonMode = true;
thumbLoader4.buttonMode = true;
thumbLoader5.buttonMode = true;
thumbLoader6.buttonMode = true;
thumbLoader7.buttonMode = true;
thumbLoader8.buttonMode = true;
thumbLoader9.buttonMode = true;
thumbLoader10.buttonMode = true;
thumbLoader11.buttonMode = true;
thumbLoader12.buttonMode = true;
thumbLoader13.buttonMode = true;
thumbLoader14.buttonMode = true;
thumbLoader15.buttonMode = true;
thumbLoader16.buttonMode = true;
thumbLoader17.buttonMode = true;
// Add event listeners for each thumb CLICK function
thumbLoader1.addEventListener(MouseEvent.CLICK, thumb1click);
thumbLoader2.addEventListener(MouseEvent.CLICK, thumb2click);
thumbLoader3.addEventListener(MouseEvent.CLICK, thumb3click);
thumbLoader4.addEventListener(MouseEvent.CLICK, thumb4click);
thumbLoader5.addEventListener(MouseEvent.CLICK, thumb5click);
thumbLoader6.addEventListener(MouseEvent.CLICK, thumb6click);
thumbLoader7.addEventListener(MouseEvent.CLICK, thumb7click);
thumbLoader8.addEventListener(MouseEvent.CLICK, thumb8click);
thumbLoader9.addEventListener(MouseEvent.CLICK, thumb9click);
thumbLoader10.addEventListener(MouseEvent.CLICK, thumb10click);
thumbLoader11.addEventListener(MouseEvent.CLICK, thumb11click);
thumbLoader12.addEventListener(MouseEvent.CLICK, thumb12click);
thumbLoader13.addEventListener(MouseEvent.CLICK, thumb13click);
thumbLoader14.addEventListener(MouseEvent.CLICK, thumb14click);
thumbLoader15.addEventListener(MouseEvent.CLICK, thumb15click);
thumbLoader16.addEventListener(MouseEvent.CLICK, thumb16click);
thumbLoader17.addEventListener(MouseEvent.CLICK, thumb17click);
// Add event listeners for each thumb ROLL_OVER function
thumbLoader1.addEventListener(MouseEvent.ROLL_OVER, thumb1over);
thumbLoader2.addEventListener(MouseEvent.ROLL_OVER, thumb2over);
thumbLoader3.addEventListener(MouseEvent.ROLL_OVER, thumb3over);
thumbLoader4.addEventListener(MouseEvent.ROLL_OVER, thumb4over);
thumbLoader5.addEventListener(MouseEvent.ROLL_OVER, thumb5over);
thumbLoader6.addEventListener(MouseEvent.ROLL_OVER, thumb6over);
thumbLoader7.addEventListener(MouseEvent.ROLL_OVER, thumb7over);
thumbLoader8.addEventListener(MouseEvent.ROLL_OVER, thumb8over);
thumbLoader9.addEventListener(MouseEvent.ROLL_OVER, thumb9over);
thumbLoader10.addEventListener(MouseEvent.ROLL_OVER, thumb10over);
thumbLoader11.addEventListener(MouseEvent.ROLL_OVER, thumb11over);
thumbLoader12.addEventListener(MouseEvent.ROLL_OVER, thumb12over);
thumbLoader13.addEventListener(MouseEvent.ROLL_OVER, thumb13over);
thumbLoader14.addEventListener(MouseEvent.ROLL_OVER, thumb14over);
thumbLoader15.addEventListener(MouseEvent.ROLL_OVER, thumb15over);
thumbLoader16.addEventListener(MouseEvent.ROLL_OVER, thumb16over);
thumbLoader17.addEventListener(MouseEvent.ROLL_OVER, thumb17over);
// Add event listeners for each thumb ROLL_OUT function
thumbLoader1.addEventListener(MouseEvent.ROLL_OUT, thumb1out);
thumbLoader2.addEventListener(MouseEvent.ROLL_OUT, thumb2out);
thumbLoader3.addEventListener(MouseEvent.ROLL_OUT, thumb3out);
thumbLoader4.addEventListener(MouseEvent.ROLL_OUT, thumb4out);
thumbLoader5.addEventListener(MouseEvent.ROLL_OUT, thumb5out);
thumbLoader6.addEventListener(MouseEvent.ROLL_OUT, thumb6out);
thumbLoader7.addEventListener(MouseEvent.ROLL_OUT, thumb7out);
thumbLoader8.addEventListener(MouseEvent.ROLL_OUT, thumb8out);
thumbLoader9.addEventListener(MouseEvent.ROLL_OUT, thumb9out);
thumbLoader10.addEventListener(MouseEvent.ROLL_OUT, thumb10out);
thumbLoader11.addEventListener(MouseEvent.ROLL_OUT, thumb11out);
thumbLoader12.addEventListener(MouseEvent.ROLL_OUT, thumb12out);
thumbLoader13.addEventListener(MouseEvent.ROLL_OUT, thumb13out);
thumbLoader14.addEventListener(MouseEvent.ROLL_OUT, thumb14out);
thumbLoader15.addEventListener(MouseEvent.ROLL_OUT, thumb15out);
thumbLoader16.addEventListener(MouseEvent.ROLL_OUT, thumb16out);
thumbLoader17.addEventListener(MouseEvent.ROLL_OUT, thumb17out);
// Set what happens to white backgrounds on their OVER state
function thumb1over(event:MouseEvent):void { whiteBG1.gotoAndPlay("over"); }
function thumb2over(event:MouseEvent):void { whiteBG2.gotoAndPlay("over"); }
function thumb3over(event:MouseEvent):void { whiteBG3.gotoAndPlay("over"); }
function thumb4over(event:MouseEvent):void { whiteBG4.gotoAndPlay("over"); }
function thumb5over(event:MouseEvent):void { whiteBG5.gotoAndPlay("over"); }
function thumb6over(event:MouseEvent):void { whiteBG6.gotoAndPlay("over"); }
function thumb7over(event:MouseEvent):void { whiteBG7.gotoAndPlay("over"); }
function thumb8over(event:MouseEvent):void { whiteBG8.gotoAndPlay("over"); }
function thumb9over(event:MouseEvent):void { whiteBG9.gotoAndPlay("over"); }
function thumb10over(event:MouseEvent):void { whiteBG10.gotoAndPlay("over"); }
function thumb11over(event:MouseEvent):void { whiteBG11.gotoAndPlay("over"); }
function thumb12over(event:MouseEvent):void { whiteBG12.gotoAndPlay("over"); }
function thumb13over(event:MouseEvent):void { whiteBG13.gotoAndPlay("over"); }
function thumb14over(event:MouseEvent):void { whiteBG14.gotoAndPlay("over"); }
function thumb15over(event:MouseEvent):void { whiteBG15.gotoAndPlay("over"); }
function thumb16over(event:MouseEvent):void { whiteBG16.gotoAndPlay("over"); }
function thumb17over(event:MouseEvent):void { whiteBG17.gotoAndPlay("over"); }
// Set what happens to white backgrounds on their OUT state
function thumb1out(event:MouseEvent):void { whiteBG1.gotoAndPlay("out"); }
function thumb2out(event:MouseEvent):void { whiteBG2.gotoAndPlay("out"); }
function thumb3out(event:MouseEvent):void { whiteBG3.gotoAndPlay("out"); }
function thumb4out(event:MouseEvent):void { whiteBG4.gotoAndPlay("out"); }
function thumb5out(event:MouseEvent):void { whiteBG5.gotoAndPlay("out"); }
function thumb6out(event:MouseEvent):void { whiteBG6.gotoAndPlay("out"); }
function thumb7out(event:MouseEvent):void { whiteBG7.gotoAndPlay("out"); }
function thumb8out(event:MouseEvent):void { whiteBG8.gotoAndPlay("out"); }
function thumb9out(event:MouseEvent):void { whiteBG9.gotoAndPlay("out"); }
function thumb10out(event:MouseEvent):void { whiteBG10.gotoAndPlay("out"); }
function thumb11out(event:MouseEvent):void { whiteBG11.gotoAndPlay("out"); }
function thumb12out(event:MouseEvent):void { whiteBG12.gotoAndPlay("out"); }
function thumb13out(event:MouseEvent):void { whiteBG13.gotoAndPlay("out"); }
function thumb14out(event:MouseEvent):void { whiteBG14.gotoAndPlay("out"); }
function thumb15out(event:MouseEvent):void { whiteBG15.gotoAndPlay("out"); }
function thumb16out(event:MouseEvent):void { whiteBG16.gotoAndPlay("out"); }
function thumb17out(event:MouseEvent):void { whiteBG17.gotoAndPlay("out"); }
// Assign variable names and URLRequest for each big pic here
var img1Req:URLRequest = new URLRequest(galleryFolder + "/Images00001.jpg");
var img2Req:URLRequest = new URLRequest(galleryFolder + "/Images00002.jpg");
var img3Req:URLRequest = new URLRequest(galleryFolder + "/Images00003.jpg");
var img4Req:URLRequest = new URLRequest(galleryFolder + "/Images00004.jpg");
var img5Req:URLRequest = new URLRequest(galleryFolder + "/Images00005.jpg");
var img6Req:URLRequest = new URLRequest(galleryFolder + "/Images00006.jpg");
var img7Req:URLRequest = new URLRequest(galleryFolder + "/Images00007.jpg");
var img8Req:URLRequest = new URLRequest(galleryFolder + "/Images00008.jpg");
var img9Req:URLRequest = new URLRequest(galleryFolder + "/Images00009.jpg");
var img10Req:URLRequest = new URLRequest(galleryFolder + "/Images00010.jpg");
var img11Req:URLRequest = new URLRequest(galleryFolder + "/Images00011.jpg");
var img12Req:URLRequest = new URLRequest(galleryFolder + "/Images00012.jpg");
var img13Req:URLRequest = new URLRequest(galleryFolder + "/Images00013.jpg");
var img14Req:URLRequest = new URLRequest(galleryFolder + "/Images00014.jpg");
var img15Req:URLRequest = new URLRequest(galleryFolder + "/Images00015.jpg");
var img16Req:URLRequest = new URLRequest(galleryFolder + "/Images00016.jpg");
var img17Req:URLRequest = new URLRequest(galleryFolder + "/Images00017.jpg");
// Assign variable name for the Loader, for use in our functions below
var big_pic:Loader = new Loader();
// Set first big pic into the frame now so it is not empty at start up, and display caption 1 with the next 3 lines
big_pic.load(img1Req);
frame_mc.addChild(big_pic);
caption_txt.text = "C EST MAGIC, Revista musical y humoristica, SALA EL CLUB DEL BUFON";
// Now we code out each thumb button function, what it does when clicked
// I will comment out and explain the first, all the rest are almost identical to the first
function thumb1click(event:MouseEvent):void {
   // Load the image from URL in "img1Req" above into big_pic
    big_pic.load(img1Req);
   // Remove any pic in the frame presently
   frame_mc.removeChildAt(1);
   // Add the picture # 1 into the big frame movieclip on stage
    frame_mc.addChild(big_pic);
   // Place the correct caption into the dynamic text field on stage
   caption_txt.text = "bleeebleebleee";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thumb2click(event:MouseEvent):void {
    big_pic.load(img2Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "bleeebleebleee";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

function thumb3click(event:MouseEvent):void {
    big_pic.load(img3Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "bleeebleebleee";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

function thumb4click(event:MouseEvent):void {
    big_pic.load(img4Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "bleeebleebleee";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

function thumb5click(event:MouseEvent):void {
    big_pic.load(img5Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "bleeebleebleee";
}
function thumb6click(event:MouseEvent):void {
    big_pic.load(img6Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "bleeebleebleee";
}
function thumb7click(event:MouseEvent):void {
    big_pic.load(img7Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "bleeebleebleee";
}
function thumb8click(event:MouseEvent):void {
    big_pic.load(img8Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "bleeebleebleee";
}
function thumb9click(event:MouseEvent):void {
    big_pic.load(img9Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "blablabla";
}
function thumb10click(event:MouseEvent):void {
    big_pic.load(img10Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "blablabla";
}
function thumb11click(event:MouseEvent):void {
    big_pic.load(img11Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "blablabla";
}
function thumb12click(event:MouseEvent):void {
    big_pic.load(img12Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "blablabla";
}
function thumb13click(event:MouseEvent):void {
    big_pic.load(img13Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "blablabla";
}
function thumb14click(event:MouseEvent):void {
    big_pic.load(img14Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "blablabla";
}
function thumb15click(event:MouseEvent):void {
    big_pic.load(img15Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "blablabla";
}
function thumb16click(event:MouseEvent):void {
    big_pic.load(img16Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "blablabla";
}
function thumb17click(event:MouseEvent):void {
    big_pic.load(img17Req);
   frame_mc.removeChildAt(1);
    frame_mc.addChild(big_pic);
   caption_txt.text = "blablabla";
}

////////////////////////////////////////////////////////////////////////////////////////////

Por CLAnonimo

Claber

600 de clabLevel

5 tutoriales
1 articulo

 

Este es un usuario anónimo genérico para las cuentas borradas o perdidas.

chrome
Citar            
MensajeEscrito el 13 Oct 2010 08:53 pm
w0w, vaya porqueria de código.

Really... ¿Eso posteas?...

En fín, el error te advierte que quitas algo del DisplayObject que no existe. Ergo, tira error.

Por Hernán

BOFH

6148 de clabLevel

19 tutoriales
23 articulos

Genero:Masculino   REC Desarrollador de GAIA

Marketing & IT

firefox
Citar            
MensajeEscrito el 13 Oct 2010 08:57 pm
Cuando ponen 300 líneas de código aplico lo que se llama "busqueda olfativa" mirando muuy rápido.
Veo que tenes hardcoded este nivel:

frame_mc.removeChildAt(1);

¿Por que nivel 1?

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 13 Oct 2010 09:37 pm
Jorge,
no se mi buen amigo, porque cuando puse "frame_mc.removeChildAt();"
me decia que se esperaba (1) ...
la verdad que mucho no entiendo. cual sera el problema?, todo funciona bien, menos lo de los titulos... :cry:

Por CLAnonimo

Claber

600 de clabLevel

5 tutoriales
1 articulo

 

Este es un usuario anónimo genérico para las cuentas borradas o perdidas.

chrome
Citar            
MensajeEscrito el 13 Oct 2010 11:38 pm
La verdad... no es verdad, no entiendes. Pero bueno, lo que te esta diciendo es que le pases AL MENOS un parametro, no 1. Please, es lectura, no coding. Quizá estes más cómodo siendo barrendero... pero bueno.

Lo que tienes que eliminar es el level0, no el 1. Empieza a contar desde 0 el stack del DisplayObject:

Código ActionScript :

frame_mc.removeChildAt(0);


Aunque en tu caso, le pondría un try:

Código ActionScript :

try(){
   frame_mc.removeChildAt(0);
}
catch(e:Error):{
   trace("wow, sigue sin funcionar");
}


Saludos, Hernán . -

Por Hernán

BOFH

6148 de clabLevel

19 tutoriales
23 articulos

Genero:Masculino   REC Desarrollador de GAIA

Marketing & IT

firefox
Citar            
MensajeEscrito el 13 Oct 2010 11:58 pm
La verdad es que casi no lo había mirado, pero sigue la premisa "si funcionó una vez, funcionará 100 veces" :)

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 14 Oct 2010 12:07 am
Funcionó perfecto. Gracias por la ayuda, aunque innecesario el trato..

Saludos!

Por CLAnonimo

Claber

600 de clabLevel

5 tutoriales
1 articulo

 

Este es un usuario anónimo genérico para las cuentas borradas o perdidas.

chrome
Citar            
MensajeEscrito el 14 Oct 2010 01:01 am
por cierto, alguno sabe como y donde puedo aplicar la propiedad smoothing en este codigo?? para que se vean bien las imagenes cuando cada thumb las llame? :shock:

Por CLAnonimo

Claber

600 de clabLevel

5 tutoriales
1 articulo

 

Este es un usuario anónimo genérico para las cuentas borradas o perdidas.

chrome

 

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