7 Replies Latest reply on Oct 8, 2011 1:50 PM by kglad

    Copying a Class

    McbainGames11 Level 2

      Hey,

       

       

      I copied my actions from frame 3 to frame 4 and frame 4's class doesn't work when frame 3's class works fine and normal, here is the source code:

       

      Frame 3:

       

      stop();
      
      var rowNum:int = 10;
      
      
      for (var i:int=0; i<rowNum; i++)
      {
      
          var enemy1:newchars = new newchars(i);
      
          enemy1.addEventListener(Event.ENTER_FRAME, GravityFall);
      
          addChild(enemy1);
      
      }
      
      function GravityFall(event:Event):void
      {
      
          var enemy1:newchars = newchars(event.currentTarget);
      
          enemy1.y +=  2;
      
      }
      
      var timer:int = 0;
      
      var TimerSpeed:uint = 1000;
      var MyTimer = new Timer(TimerSpeed);
      MyTimer.addEventListener(TimerEvent.TIMER, TimerHandler);
      
      function TimerHandler(e:TimerEvent):void
      {
          
          timer +=  1;
      
          if (timer == 50)
          {
      
              
              removeEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler100);
              MyTimer.removeEventListener(TimerEvent.TIMER, TimerHandler);
              
              MyTimer.stop();
              gotoAndPlay(4);
      
          }
      
      }
      
      addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler100);
      
      
      function fl_EnterFrameHandler100(event:Event):void
      {
      
          Bird_1.x = mouseX;
          
          MyTimer.start();
      
      }
      

       

       

       

       

      Frame 4:

       

       

      stop();
      
      var rowNum01:int = 10;
      
      
      for (var a:int=0; a<rowNum; a++)
      {
      
          var enemy2:newchars = new newchars(a);
      
          enemy2.addEventListener(Event.ENTER_FRAME, GravityFall01);
      
          addChild(enemy1);
      
      }
      
      function GravityFall01(event:Event):void
      {
      
          var enemy2:newchars = newchars(event.currentTarget);
      
          enemy2.y +=  2;
      
      }
      
      var timer01:int = 0;
      
      var TimerSpeed01:uint = 1000;
      var MyTimer01 = new Timer(TimerSpeed01);
      MyTimer01.addEventListener(TimerEvent.TIMER, TimerHandler01);
      
      function TimerHandler01(e:TimerEvent):void
      {
          
          timer01 +=  1;
      
          if (timer01 == 50)
          {
      
              
              removeEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler10001);
              MyTimer.removeEventListener(TimerEvent.TIMER, TimerHandler01);
              
              MyTimer01.stop();
              gotoAndPlay(5);
      
          }
      
      }
      
      addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler10001);
      
      
      function fl_EnterFrameHandler10001(event:Event):void
      {
      
          Bird_101.x = mouseX;
          
          MyTimer01.start();
      
      }