1 Reply Latest reply on Jan 23, 2007 8:45 PM by kglad

    Deleting a MC if it's off stage

    Jimmathy
      Im having a problem seeting up my actionscript so that when the MC(which is created and put into motion via actionscript) leaves the stage it will be deleted... I have a buttload of actionscript for you guys to sift through:

      stop();
      z=1000;
      q=1;
      w=1;
      i=1;
      score = 0;
      k=attachMovie("car","car", 500);
      k._x = 70;
      k._y = 200;
      setInterval(check,10);
      setInterval(drive, 25);
      setInterval(kill,z);
      setInterval(lvlup,2000);
      setInterval(rocks,2600);
      function check(){
      if(i > 400){
      i=1}
      if(q >400){
      q=1}
      if(w >400){
      w=1;}
      if(car._x<0){
      gotoAndPlay("gameover")
      }}
      function drive(){
      if(Key.isDown(Key.UP)){
      _root.car._y -= 4;
      _root.car._rotation = -15;
      _root.holder._x = _root.car._x;
      _root.holder._y = _root.car._y;
      }
      else if(Key.isDown(Key.DOWN)){
      _root.car._y += 4;
      _root.car._rotation = 15;
      _root.holder._x = _root.car._x;
      _root.holder._y = _root.car._y;
      }
      else{_root.car._rotation = 0;
      }}
      function kill(){
      rk=_root.attachMovie("squirrel", "squirrel"+i, -i);
      i++;
      rk._rotation = Math.random()*360;
      rk._y = Math.random()*325;
      rk._x = 545;
      rk.speed=6;
      rk.movel=setInterval(moveF,30,rk);
      }
      function moveF(mc){
      mc._x -= mc.speed;
      if(mc.hitTest(_root.car)){
      mc.gotoAndStop("death");}
      }
      function lvlup(){
      z = 10;
      }
      function rocks(){
      rok=_root.attachMovie("rock", "rock"+w, w);
      w++;
      rok._rotation = Math.random()*360;
      rok._y = Math.random()*300;
      rok._x = 545;
      rok.speed=6;
      rok.movel=setInterval(moveRoc,30,rok);
      }
      function moveRoc(mb){
      mb._x -= mb.speed;
      if(mb.hitTest(_root.car)){
      car.gotoAndStop("boom");
      car.speed= 6;
      car.moved=setInterval(cardied,30,car);}
      }
      function cardied(){
      car._x -= car.speed;}
      I need to figure out how to make the car, squirrel(AKA "rk" or "mc"), and the rock(AKA "rok" or "mb") to be deleted when they move off the left of the stage. I know my coding is not set up in a pretty way, but im a noob :P, so please tell me what to add to which part of the code.
      thanks