Comunidad de diseño web y desarrollo en internet online

No quiere ejecutar evento removeEventListener

Citar            
MensajeEscrito el 23 Jul 2008 10:26 pm
Un favor tengo este codigo en el cual al monento de ejecutar el remove..me dice que la variable timer1 no esta definido



Código :

function main ():void
{



   for (var z:int=z; z<=numinstancias; z++)
   {
       var timer1:Timer=new Timer(1);
      var instancia:int=evaluadistancia();
      this.instancia.text=instancia;
      timer1.addEventListener (TimerEvent.TIMER,mover);
      timer1.start ();
   }
}


// Evento que mueve el clip

function mover (event:TimerEvent):void
{
   var t:triangulo=new triangulo();

   t=getChildByName("triangulo"+this.instancia.text);

   if (t.numero.visible==true)
   {

      if ( t.hitTestObject( this.n ))
      {
         // lo marca con una señal
         t.numero.visible=false
         ;
         // destruye el timer
         timer1.removeEventListener(TimerEvent.TIMER,mover)
         //timer1.stop();
      }
      else
      {

         if (this.n.x >= t.x )
         {
            coord = "x";
            dir = -1;
         }
         if (this.n.y>= t.y)
         {
            coord = "y";
            dir = -1;
         }
         if (this.n.x < t.x)
         {
            coord = "x";
            dir = 1;
         }
         if (this.n.y < t.y)
         {
            coord = "y";
            dir = 1;
         }
         this.n[coord] += vel*dir;

      }
   }
}


Por favor si alguien me podria decir por que y como solucionarlos.....muchas gracias

Por pdjazr

6 de clabLevel



Genero:Masculino  

Lima -Limon

msie
Citar            
MensajeEscrito el 24 Jul 2008 02:01 am
la variable timer esta declarada dentro de la función main(), tienes que ponerla fuera de las funciones para que cualquiera los soporte, o bien, declarala otra vez en la funcion mover:

Código :

var timer1:Timer = e.currentTarget as Timer;

Por master_of_puppetz

Claber

2483 de clabLevel

7 tutoriales
3 articulos

Genero:Masculino   Premio_Secretos

WebDev (Flex + PHP + JS)

safari

 

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