In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

flash on 2016-3-1

Get Adobe Flash player
by mutantleg 01 Mar 2016
    Embed
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/MyDI
 */

package {
    import flash.text.TextField;
    import flash.events.Event;
    import flash.display.Graphics;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {           
            deb = new TextField();
             deb.width=320;deb.height=240;
             deb.mouseEnabled=false;
            addChild(deb); 
            
            vecAct = new Vector.<xAct>(0,false);
            
            stage.addEventListener(Event.ENTER_FRAME, onEnter);            
        }//ctor
        
         public var deb:TextField; 
        
        /*
        public var gx:Number = 30;
        public var gy:Number = -40;
        public var gnum:int = 0;
        public var gwait:int = 16;
        public var gmode:int = 0;
*/

        public function addEnc(ax:Number, ay:Number=-40, num:int=8, mode:int = 0, wait:int=16):void
        {
          var a:xEnc;
          a = new xEnc();
           a.cx = ax; a.cy = ay;
           a.gx=ax; a.gy=ay;
           a.gnum = num;
           a.gmode = mode;
           a.gwait =wait;
          vecAct.push(a);  
        }//addenc
        
        public function onEnter(e:Event):void
        {
            graphics.clear();
            graphics.lineStyle(2, 0);

          var i:int; var num:int;
          num = 2;
          for (i=0;i<num;i+=1)
          {          
            updateVec(vecAct); renderVec(vecAct);

            if (gt == 20)  { addEnc(40, -40, 8, 0, 16);  }
            if (gt == 80)  { addEnc(340, -40, 8, 1, 16);  }
            
            
            if (gt > 90 && (gt % 40 == 0))  { addEnc(Math.random()*400, -40, 8, Math.random()*2, 16);  }

            
            deb.text = ""+gt + "\n"+vecAct.length;
            gt += 1;
          }//nexti
          return;  

/*
            var a:xAct;            
            if (gnum > 0 && gt % gwait == 0)
            {
              a = new xShip(); a.cx =gx; a.cy=gy;              
              a.mode = gmode;
              vecAct.push(a);
              gnum -= 1;  
            }//endif
            
 */           
/*            
            var a:xAct;
            if (gt % 16 == 0)
            {
                a = new xShip(); a.cx = 30; a.cy= -30;
                a.cx = 300; a.mode = 1;
                vecAct.push(a);
                
             }
 */
            
            deb.text = ""+gt;
            gt += 1;
        }//onenter
 
        public static var gt:int = 0;
        public static var vecAct:Vector.<xAct>; 
    
        public function renderVec(vec:Vector.<xAct>):void
        { var i:int; var num:int; var a:xAct;
           num = vec.length; for(i=0;i<num;i+=1)
           { a = vec[i]; if (a==null || a.hp <=0) { continue; }
           graphics.drawCircle(a.cx,a.cy, a.rad); }
        }//render
        
        public function updateVec(vec:Vector.<xAct>):void
        { var i:int; var num:int; var a:xAct; var k:int; 
           num = vec.length;   for(i=0;i<num;i+=1)
           { a = vec[i];  if (a ==null || a.hp <= 0)
             { for (k=i;k<num-1;k+=1)  { vec[k]=vec[k+1]; }   
               vec.pop(); num-=1; i-=1; continue; }  a.update(); 
           }//nexti
        }//update
        
    }//classend
}
       
internal class xAct {
  public var cx:Number = 0;  public var cy:Number = 0;
  public var vx:Number = 0;  public var vy:Number = 0;
  public var rad:Number = 8; public var ang:Number = 0;
  public var hp:Number = 10;
  public var mode:int = 0;
  public var wa:int = 0;
  public function update():void {}
}//xactor

internal class xEnc extends xAct
{ 
 public var gx:Number = 30;
 public var gy:Number = -40; 
 public var gnum:int = 0; 
 public var gwait:int = 16;
 public var gmode:int = 0;
    
  override public function update():void 
  {
    var a:xAct;            
        if (gnum > 0 && FlashTest.gt % gwait == 0)
        {
          a = new xShip(); a.cx =gx; a.cy=gy;              
          a.mode = gmode;
          FlashTest.vecAct.push(a);
          gnum -= 1;  
        }//endif
        
  }//update    
}//xenc



internal class xShip extends xAct
{
    
  override public function update():void 
  {
      if (mode == 0)
      {
        if (vx<2 &&wa>0) { vx +=0.2; }  
        vy+=0.2; if (vy>7) {vy=7;}
        if (vy>=0 && cy >= 300 && wa < 1) { vx=0; vy = -7; wa+=1; }
        if (cy > 430){ hp =-1;}
      } 
      else
      {
        if (vx>-2&&wa>0) { vx -=0.2; }  
        vy+=0.2; if (vy>7) {vy=7;}
        if (vy>=0 && cy >= 300 && wa < 1) { vx=0; vy = -7; wa+=1; }
        if (cy > 430){ hp =-1;}
      }//endif
      
      
    cx+=vx; cy+=vy;      
      
  }//xupdate
    
}//xship