Comunidad de diseño web y desarrollo en internet online

marcar desmarcar botones XML

Citar            
MensajeEscrito el 09 Oct 2008 02:48 am
Vuelvo a molestarlos por que tengo una duda que me gustaria resolver, tengo un xml en este hay unos botones y me gustaria que cuando cliquee en uno de estos quede marcado y que despues al cliquear en otro el anterior se desmarque.
Creo que esta ves por fin lo que dije tiene un orden logico :lol:

Este es el codigo que estoy usando

Código :

function loadXml(file:String) {
   menuXml.ignoreWhite = true;
   menuXml.onLoad = loadMapData;
   menuXml.load(file);
   function loadMapData() {
      for (var i = 0; i<this.firstChild.childNodes.length; i++) {
         var bn = this.firstChild.childNodes[i].attributes.buttonName;
         var t = this.firstChild.childNodes[i].attributes.thumbs;
         var b = _root.btn.bM1.attachMovie("button", bn, i);
         b.pic_url = this.firstChild.childNodes[i].attributes.full_url;
         b.pic_url2 = this.firstChild.childNodes[0].attributes.full_url;
         b._x = xStart+((bWidth+2)*i);
         b._y = yStart;
         b.txt = bn;
         loadMovie(t, b.foto);
         b.onPress = function() {
            if (loaded == filesize) {
               contenedor._alpha = 0;
               contenedor.loadMovie(this.pic_url);
            }
         };
         b.onRollOver = function() {
            this.t2._y = 20;
            this.t2._alpha = 0;
            Tweener.addTween(this.t1,{_alpha:0, _y:-10, time:0.5});
            Tweener.addTween(this.t2,{_alpha:80, _y:0, time:0.5, onStart:function () {
            this._visible = true;
            }});
            Tweener.addTween(this.foto,{_alpha:100, time:1, onStart:function () {
            this._visible = true;
            }});
         };
         b.onRollOut = function() {
            Tweener.addTween(this.t1,{_alpha:100, _y:0, time:0.5});
            this.t2._visible = false;
            this.foto._visible = false;
         };
      }
   }
}

Por boruga

21 de clabLevel



 

safari
Citar            
MensajeEscrito el 09 Oct 2008 11:41 am
Mira este post, te puede ayudar.

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 13 Oct 2008 01:56 am
No di con la forma de solucion, intente poner el codigo del otro post pero no me funciono, creo que no entiendo muy bien este codigo

Por boruga

21 de clabLevel



 

safari
Citar            
MensajeEscrito el 13 Oct 2008 01:51 pm
La idea no es poner el código, sino leerlo y tratar de comprenderlo para que lo apliques a tus necesidades, de no entender postea exactamente la parte que no entienedes y tratré de explicártela.

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 28 Oct 2008 05:11 am
Si lo acepto me fui por la via facil, bueno te esplico a ver si me podes ayudar, no habia vuelto a mirar la pagina ya que me encontraba de paseo. Bueno he aplicado el codigo y entiendo, pero el problema es que no se aplicarlo a mi caso especifico. Voy a poner el codigo como lo aplique y voy paso a paso lo que no entendi.


Bueno te esplico, puse el codigo de la forma que esta abajo. Pero no entiendo, como el codigo de la funcion lo puedo aplicar dentro del mio y que le tengo que decir al boton, aqui estoy usando caurina para poder mover los botones, y en tu ejemplo es con frames.

No se si el error lo tengo en la funcion o en el onPress. Entiendo la funcion de lo que me has dado, pero no se aplicarlo.

Código :

function loadXml(file:String) {
   menuXml.ignoreWhite = true;
   menuXml.onLoad = loadMapData;
   menuXml.load(file);
   function loadMapData() {
      for (var i = 0; i<this.firstChild.childNodes.length; i++) {
         var bn = this.firstChild.childNodes[i].attributes.buttonName;
         var t = this.firstChild.childNodes[i].attributes.thumbs;
         var b = _root.btn.bM1.attachMovie("button", bn, i);
         b.pic_url = this.firstChild.childNodes[i].attributes.full_url;
         b.pic_url2 = this.firstChild.childNodes[0].attributes.full_url;
         b._x = xStart+((bWidth+2)*i);
         b._y = yStart;
         b.txt = bn;
         loadMovie(t, b.foto);

                        //aqui aplique la funcion
         function desactiva(button:MovieClip):Void {
            var mc:MovieClip;
            for (var i:Number = 1; i<=cantidad; i++) {
               mc = this["button"+i];
               //---Habilitar o deshabilitar el boton
               mc.enabled = (mc == boton) ? false : true;
               //---Si el botón no es el presionado ir al frame _up
               if (mc != button) {
                  Tweener.addTween(this.t1,{_alpha:100, _y:0, time:0.5});
                  this.t2._visible = false;
               }
            }
         }
                        //---------------------------------------------------

         b.onPress = function() {

                        //aqui aplique el desactiva
            desactiva(this);
                        //---------------------------------------------------

            if (loaded == filesize) {
               contenedor._alpha = 0;
               contenedor.loadMovie(this.pic_url);
            }
         };
         b.onRollOver = function() {
            this.t2._y = 20;
            this.t2._alpha = 0;
            Tweener.addTween(this.t1,{_alpha:0, _y:-10, time:0.5});
            Tweener.addTween(this.t2,{_alpha:80, _y:0, time:0.5, onStart:function () {
            this._visible = true;
            }});
            Tweener.addTween(this.foto,{_alpha:100, time:1, onStart:function () {
            this._visible = true;
            }});
         };
         b.onRollOut = function() {
            Tweener.addTween(this.t1,{_alpha:100, _y:0, time:0.5});
            this.t2._visible = false;
            this.foto._visible = false;
         };
      }
   }
}


Gracias de antemano y que pena responder hasta ahora

Por boruga

21 de clabLevel



 

safari
Citar            
MensajeEscrito el 03 Nov 2008 06:29 pm
No se si funcionará porque son demasiadas cosas, lo mejor es ir paso a paso, pero por lo pronto analiza el código que posteo, he cambiado algunas cosas del tuyo, principalmente sacar las funciones de dentro de la función de onLoad, igualar la variable "mc" a el movieClip correcto según la forma en que los has creado y hacer el Tween exactamente en los movieclips que declaras en el rollOver y rollOut. Revisa el código, analízalo y trata de variar tu código hasta que te funcione sin problemas.

Código ActionScript :

var nodos:Array;

function loadXml(file:String) {

   menuXml.ignoreWhite = true;

   menuXml.onLoad = function():Void  {

      nodos = this.firstChild.childNodes;
      var bn:String;
      var t:String;
      var b:MovieClip;

      for (var i = 0; i < nodos.length; i++) {

         bn = nodos[i].attributes.buttonName;
         t = nodos[i].attributes.thumbs;
         b = _root.btn.bM1.attachMovie("button", bn, i);
         b.numero = i;

         b.pic_url = nodos[i].attributes.full_url;
         b.pic_url2 = nodos[0].attributes.full_url;
         b._x = xStart + ((bWidth + 2) * i);
         b._y = yStart;
         b.txt = bn;

         loadMovie(t, b.foto);

         //---Acciones de los botones

         b.onPress = function() {

            //aqui aplique el desactiva
            desactiva(this);
            //---------------------------------------------------

            if (loaded == filesize) {
               contenedor._alpha = 0;
               contenedor.loadMovie(this.pic_url);
            }
         };
         
         b.onRollOver = function() {
            this.t2._y = 20;
            this.t2._alpha = 0;
            Tweener.addTween(this.t1,{_alpha:0, _y:-10, time:0.5});
            Tweener.addTween(this.t2,{_alpha:80, _y:0, time:0.5, onStart:function () {
            this._visible = true;
            }});
            Tweener.addTween(this.foto,{_alpha:100, time:1, onStart:function () {
            this._visible = true;
            }});
         };
         b.onRollOut = function() {
            Tweener.addTween(this.t1,{_alpha:100, _y:0, time:0.5});
            this.t2._visible = false;
            this.foto._visible = false;
         };
      }
   };
   menuXml.load(file);
}

//Función de desactivar
function desactiva(button:MovieClip):Void {
   
   var mc:MovieClip;
   var bn:String;
   
   for (var i:Number = 1; i <= cantidad; i++) {
      
      bn = nodos[i - 1].attributes.buttonName;
      mc = _root.btn.bM1[bn];
      //---Habilitar o deshabilitar el boton
      mc.enabled = (mc == boton) ? false : true;
      //---Si el botón no es el presionado ir al frame _up
      if (mc != button) {
         Tweener.addTween(mc.t1,{_alpha:100, _y:0, time:0.5});
         mc.t2._visible = false;
      }
   }
}

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox

 

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