Comunidad de diseño web y desarrollo en internet online

problemas con menú acordeón

Citar            
MensajeEscrito el 22 May 2008 03:52 pm
Buenas,
me descargué el código de un menú en acordeón ( http://www.visual-blast.com/flash/ac...le-flash-menu/ ) que me interesa bastante y estoy intentando que al abrirse cada menú, cargue un .swf externo diferente y no sé por qué siempre me carga el numero 7. Os envío la modificación del código que he hecho a ver si pudiérais aclararme qué pasa, porque me estoy volviendo tarumba!


Código :

stop();
speed = 5;
initial_width = 75;
target_width = 800;
sp = rect1._x;

this.createEmptyMovieClip(\"emptymc\", 0);
emptymc.onEnterFrame = function() {   
for (i=1; i<=7; i++) {
   if (_root.hit.hitTest(_root._xmouse, _root._ymouse, true)) {
      if (_root[\"rect\"+i].hitTest(_root._xmouse, _root._ymouse, true)) {
         new_x = (_root.sp-(75*(i-1)))-rect1._x;
         rect1._x += new_x/speed;
         n_width = target_width-_root[\"rect\"+i]._width;
         _root[\"rect\"+i]._width += n_width/speed;
         } else {
         n_width2 = initial_width-_root[\"rect\"+i]._width;
         _root[\"rect\"+i]._width += n_width2/speed;


         }
   } else {
      
      new_x = _root.sp-rect1._x;
      rect1._x += new_x/(speed+50);
      n_width2 = initial_width-_root[\"rect\"+i]._width;
      _root[\"rect\"+i]._width += n_width2/(speed-1);
      _root.mc.loadMovie(\"vinos\"+i+\".swf\", 0);
   }
   _root[\"rect\"+(i+1)]._x = _root[\"rect\"+i]._x+_root[\"rect\"+i]._width;
   _root[\"movie\"+i]._x = _root[\"rect\"+i]._x-1;

   }
};



En la linea 28 he añadido



Código :

_root.mc.loadMovie(\"vinos\"+i+\".swf\", 0);



y debería cargar vinos1.swf al seleccionar el menú 1, vinos2.swf al seleccionar el menú 2... etc hasta llegar a 7, pero como he dicho siempre me carga vinos7.swf.

Debo decir que primero probé a ponerlo tras


Código :

if (_root[\"rect\"+i].hitTest(_root._xmouse, _root._ymouse, true)) {



creo que eso sería lo lógico pero el problema es que, aunque me carga el swf correcto, lo hace cuando el cursor sale del área \"hitTesteada\" (palabro raro, no sé si me explico) digamos que cuando se cierra la sección se carga el .swf

Por eso he ido probando hasta que me lo ha cargado en su momento (cuando se abre la sección, pero el swf incorrecto.

¿es posible que l resto del código impida que se vea la carga? ¿Como podría adaptarse a onPress?

No sé si me he explicado bien, por favor, ayudadme porque no sé ya que hacer...
Muchas gracias.

Por elhada.teresika

27 de clabLevel



 

firefox
Citar            
MensajeEscrito el 22 May 2008 07:12 pm
Prueba, fuera del onEnterFrame

Código :

for (i=1; i<=7; i++) {
 _root["rect"+i].onPress = function(){
   v ar nr = this._name.substr(4)
   _root.mc.loadMovie("vinos"+this.nr+".swf");
 }
}


Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 23 May 2008 10:37 am
Hola Solisarg , gracias por tu respuesta, pero me temo que me sigue cargando vinos7.swf...
creo que hoy lo dejo zanjado aunque tenga que hacer otra página... Shock

Un saludo,
Elhada

Por elhada.teresika

27 de clabLevel



 

firefox
Citar            
MensajeEscrito el 23 May 2008 10:43 am
fuera del onEnterFrame


Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 23 May 2008 10:48 am
Perdona, lo que te he dicho no es correcto. Se me había olvidado borrar mi código.
Probando lo que tu me has dicho no me carga ninguna película...
Lo he puesto aquí, a ver si es que me estoy colando...

Código :

stop();
speed = 5;
initial_width = 75;
target_width = 800;
sp = rect1._x;

this.createEmptyMovieClip("emptymc", 0);
emptymc.onEnterFrame = function() {   
for (i=1; i<=7; i++) {
   if (_root.hit.hitTest(_root._xmouse, _root._ymouse, true)) {
      if (_root["rect"+i].hitTest(_root._xmouse, _root._ymouse, true)) {
         new_x = (_root.sp-(75*(i-1)))-rect1._x;
         rect1._x += new_x/speed;
         n_width = target_width-_root["rect"+i]._width;
         _root["rect"+i]._width += n_width/speed;
         } else {
         n_width2 = initial_width-_root["rect"+i]._width;
         _root["rect"+i]._width += n_width2/speed;
         }
   } else {
      
      new_x = _root.sp-rect1._x;
      rect1._x += new_x/(speed+50);
      n_width2 = initial_width-_root["rect"+i]._width;
      _root["rect"+i]._width += n_width2/(speed-1);


   }
   _root["rect"+(i+1)]._x = _root["rect"+i]._x+_root["rect"+i]._width;
   _root["movie"+i]._x = _root["rect"+i]._x-1;

   }
for (i=1; i<=7; i++) {
 _root["rect"+i].onPress = function(){
 var nr = this._name.substr(4)
 _root.mc.loadMovie( "vinos" +this.nr+".swf");
 }
}

};

Por elhada.teresika

27 de clabLevel



 

firefox
Citar            
MensajeEscrito el 23 May 2008 11:04 am
fuera del onEnterFrame


¿Ves la llave del final? Es la que define el onEnterFrame, lo que pusiste está dentro

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 23 May 2008 11:40 am
sigue sin cargarme ninguna pelicula.... :crap:

Por elhada.teresika

27 de clabLevel



 

firefox
Citar            
MensajeEscrito el 23 May 2008 11:52 am
¿Lo pusiste en el lugar correcto?

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 23 May 2008 12:04 pm
hummm...

he probado primero aqui.....

Código :

stop();
speed = 5;
initial_width = 75;
target_width = 800;
sp = rect1._x;

this.createEmptyMovieClip("emptymc", 0);
emptymc.onEnterFrame = function() {   
for (i=1; i<=7; i++) {
   if (_root.hit.hitTest(_root._xmouse, _root._ymouse, true)) {
      if (_root["rect"+i].hitTest(_root._xmouse, _root._ymouse, true)) {
         new_x = (_root.sp-(75*(i-1)))-rect1._x;
         rect1._x += new_x/speed;
         n_width = target_width-_root["rect"+i]._width;
         _root["rect"+i]._width += n_width/speed;
         } else {
         n_width2 = initial_width-_root["rect"+i]._width;
         _root["rect"+i]._width += n_width2/speed;


         }
   } else {
      
      new_x = _root.sp-rect1._x;
      rect1._x += new_x/(speed+50);
      n_width2 = initial_width-_root["rect"+i]._width;
      _root["rect"+i]._width += n_width2/(speed-1);
   }
   _root["rect"+(i+1)]._x = _root["rect"+i]._x+_root["rect"+i]._width;
   _root["movie"+i]._x = _root["rect"+i]._x-1;

   }
}
for (i=1; i<=7; i++) {
 _root["rect"+i].onPress = function(){
   var nr = this._name.substr(4)
   _root.mc.loadMovie("vinos"+this.nr+".swf");
 }
}


y luego entre

Código :

this.createEmptyMovieClip("emptymc", 0);

y

Código :

emptymc.onEnterFrame = function() {   

Por elhada.teresika

27 de clabLevel



 

firefox
Citar            
MensajeEscrito el 23 May 2008 12:10 pm
El primero está bien. Ahora tratándose de un menú, me sorprendería que no tenga el onPress definido en algún otro lado del código, con lo que simplemente sobreescribe el tuyo

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox

 

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