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-6-19

Get Adobe Flash player
by mutantleg 18 Jun 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/WdTN
 */

package {
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            vecAct = new Vector.<xAct>(0,false);
            var i:int; var a:xAct;
            for(i=0;i<32;i+=1)
            {
              a = new xAct();
               a.cx = Math.random()*512;
               a.cy = Math.random()*1024;
              vecAct.push(a); 
            }//nexti
          stage.addEventListener(Event.ENTER_FRAME, onEnter);           
        }//ctor
        
        public var camx:Number = 0;
        public var camy:Number = 0;
        
        public var cx:Number = 230;
        public var cy:Number = 230;
        public var cz:Number = 0;
        public var vx:Number = 0;
        public var vy:Number = 0;
        public var vz:Number = 0;
        
        public var vecAct:Vector.<xAct>;
        
        public function getMag(ax:Number, ay:Number):Number
        { return Math.sqrt(ax*ax+ay*ay); }
        
        public function onEnter(e:Event):void
        {
            graphics.clear();
            graphics.lineStyle(2, 0);
            
            graphics.drawRect(0-camx,0-camy,512,1024);
            
            
            var a:xAct;
            var i:int; var num:int;
            num = vecAct.length;
            for(i=0;i<num;i+=1)
            {
              a = vecAct[i];
              
              var ms:Number; var ta:Number;
                  ta = Math.atan2(cy-a.cy,cx-a.cx);
                  ms =0.3;
                  a.vx += Math.cos(ta) * ms;
                  a.vy += Math.sin(ta)*ms;
                  ms = 3;
                   if (a.vx>ms){a.vx=ms;} else if (a.vx<-ms){a.vx=-ms;}
                   if (a.vy>ms){a.vy=ms;} else if (a.vy<-ms){a.vy=-ms;}
                   
                if (getMag(a.cx-cx,a.cy-cy)<16)
                if (Math.abs(cz-a.cz)<8)
                {
                  ms =0.6 + Math.random()*6;
                  vx += Math.cos(ta) * ms;
                  vy += Math.sin(ta)*ms;
                  vz = Math.random()*2;
                  ms = 8;
                   if (vx>ms){vx=ms;} else if (vx<-ms){vx=-ms;}
                   if (vy>ms){vy=ms;} else if (vy<-ms){vy=-ms;}
                }//endif   
                  
              var k:int; var b:xAct;
              for (k=i+1;k<num;k+=1)
              {
                 b = vecAct[k];
                 var d:Number; var dx:Number; var dy:Number;
                 dx=a.cx-b.cx; dy=a.cy-b.cy;
                 d = getMag(dx, dy);
                 if (d==0){continue;}
                 if (d<16)
                 { dx/=d; dy/=d;
                   a.vx+=dx; a.vy+=dy;
                   b.vx-=dx; b.vy-=dy;
                 }//endif
              }//nextk
              
              if (a.cy<0&&a.vy<0) { a.vy=-a.vy; a.cy=0; }
              if (a.cy>1024&&a.vy>0) { a.vy=-a.vy; a.cy=1024; }
              if (a.cx<0&&a.vx<0) { a.vx=-a.vx; a.cx=0; }
              if (a.cx>512&&a.vx>0) { a.vx=-a.vx; a.cx=512; }
              
              a.cx+=a.vx; a.cy+=a.vy;
              
                 graphics.drawEllipse(a.cx-8-camx,a.cy-2-camy+8,16,4);
                 graphics.beginFill(0xFFffFF,1);
                 graphics.drawCircle(a.cx-camx,a.cy-camy-a.cz, 8);
                 graphics.endFill();
                
            }///nexti


            graphics.drawEllipse(cx-8-camx,cy-2-camy+8,16,4);
            graphics.beginFill(0x808080,1);
            graphics.drawCircle(cx-camx,cy-camy-cz, 8);
            graphics.endFill();
            
            vx*=0.97;        vy*=0.97;
            vz -=0.1;
            
              if (cy<0&&vy<0) { vy=-vy; cy=0; }
              if (cy>1024&&vy>0) { vy=-vy; cy=1024; }
              if (cx<0&&vx<0) { vx=-vx; cx=0; }
              if (cx>512&&vx>0) { vx=-vx; cx=512; }
              if (cz<0&&vz<0){vz*=-0.5;  cz=0;}

            cx+=vx; cy+=vy; cz+= vz;
            
            
            camx = cx-235;
            camy = cy-235;
            
        }//onenter
        
    }//classend
}


internal class xAct
{
  public var cx:Number = 0;
  public var cy:Number = 0;
  public var cz:Number = 0;
  
  public var vx:Number = 0;
  public var vy:Number = 0;   
  public var col:uint = 0xFFffFF;
    
};//xact