vendredi 21 avril 2017

Cant work out why my fading script won't work

I've run across a piece of code that I'm really struggling to get working... It's meant to wait three seconds before fading an object (swslogo), however when I test it, it doesn't seem to work.. anyone know why this might be

    var GameMode:Number = 0;
    swslogo.alpha = .0;
    var IntroTimer = new Timer(4000,1); //add a 4 second timer
    IntroTimer.addEventListener(TimerEvent.TIMER_COMPLETE,swsfadein);
    intro();
    swsfadein ();
    function intro(e:Event=null):void
    {
      IntroTimer.reset()
      IntroTimer.start();
    }
    function swsfadein(e:Event=null):void
    {
      IntroTimer.stop();
      swslogo.addEventListener(Event.ENTER_FRAME, fadein)
    }
      function fadein(e:Event=null){
        if(swslogo.alpha <=0){
          this.alpha +=0.1;
          if(swslogo.alpha >=1){
            this.removeEventListener(Event.ENTER_FRAME, fadein);
          }
        }
      }

Aucun commentaire:

Enregistrer un commentaire