0 Replies Latest reply on Jul 30, 2009 3:43 PM by shintashi

    for loop vs. enter frame?

    shintashi Level 1

      Trying to make a basic Radar simulation which will later use Echo location and lots of messy math later. At the onset the idea was

      1. create a movieclip circle

      2. have the movie clip circle inside another movieclip (beacon) that fades out over 16 frames and self deletes on the 16th frame

      3. use a for loop to attach the beacon movieclips to the center of a transmitter movie clip, one frame at a time

      4. run the program and watch small dark rings appear and expand out and fade away endlessly while the program runs

      5. use keyisDown commands to control the location of the transmitter

      6. create a second transmitter to create interference patterns

       

       

      only about half the code works half the time. if I comment out the enterframe in the for loop, the transmitter moves again, but the ring doesn't expand. I have no idea how to get multiple rings to appear And expand, and only seem to be able to get the expansion to work when the transmitter doesn't move.

       

      //-----

      sgo = 55;
      vgo = 30;
      onEnterFrame = function(){
      sspeed.text = sgo * 5;
      vspeed.text = vgo * 5;

       

      transmitter._y = vgo * 5;
      transmitter._x = sgo * 5;

       


      if(Key.isDown(Key.UP)){vgo--;}
      if(Key.isDown(Key.DOWN)){vgo++;}                    
      if(Key.isDown(Key.LEFT)){sgo--;}
      if(Key.isDown(Key.RIGHT)){sgo++;}                  

       

      }

       

       

       


      for(i=0;i<1;i++) {
          var k:MovieClip = transmitter.attachMovie("beacon","beacon"+i ,transmitter.getNextHighestDepth());
              k.gotoAndPlay(1);   
          onEnterFrame = function(){k._xscale = k._yscale += 100; }
      }
      //----