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 2013-6-11

Get Adobe Flash player
by mutantleg 11 Jun 2013
    Embed
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/9zLc
 */

package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.text.TextField;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
       
       //iso with scrolling experiment thing
       
        public function FlashTest() {
       
       
           var num:int;
           var i:int;
           
           mwidth = 32;
           mheight = 32;
           
           num = mwidth * mheight;
           
           vecGrid = new Vector.<int>(num, false);
           
           bd = new BitmapData(mwidth, mheight, false, 0);
              vecCol = Vector.<uint>([0, 0x808080, 0x880000, 0x000088, 0x008800, 0x441288, 0x112233 ]);
           
           for (i = 0; i < num; i++)
           {
               vecGrid[i] = Math.random() * 4;
               bd.setPixel(i%mwidth,i/mwidth,vecCol[vecGrid[i]]);
           }//nexti
           
           pic = new Bitmap(bd);
           pic.x = 250;
           pic.scaleX = 2;
           pic.scaleY = 2;
           addChild(pic);
           
           
           deb = new TextField();
           deb.width = 320;
           deb.height = 240;
           deb.mouseEnabled = false;
           addChild(deb);
           
           
          
           
          stage.addEventListener(Event.ENTER_FRAME,onEnter);     
        }//ctor
        
        public var bd:BitmapData;
        public var pic:Bitmap;
        
        public var vecCol:Vector.<uint>;
        public var vecGrid:Vector.<int>;
        public var mwidth:int = 0;
        public var mheight:int = 0;
        public var cw:Number = 32;
        public var ch:Number = 32;
        
        
        public var camx:Number = 0;
        public var camy:Number = 0;
        
        
        public var deb:TextField;
        
        public function onEnter(e:Event):void
        {
            graphics.clear();
            graphics.lineStyle(1, 0);
            
            if (pic.mouseX >= 0 && pic.mouseY >= 0
            && pic.mouseX < pic.width && pic.mouseY < pic.height)
            { camx= pic.mouseX*cw - 128; camy = pic.mouseY*ch - 128; }
            
            var offx:Number;
            var offy:Number;
            

            var i:int;
            var k:int;
            
            var sx:int;
            var sy:int;
            var ex:int;
            var ey:int;
            var yt:int;
            var t:int;
            
            var c:int;
            
            var rx:Number; var ry:Number; var rz:Number;
            var dx:Number; var dy:Number;
            
            var kw:Number; var kh:Number;
            
            
            var ax:Number;
            var ay:Number;
            var bx:Number;
            var by:Number;
            
            ax = 64;
            ay = 64;
            bx = ax + 256;
            by = ay + 256;
            
            //camx += 1;
            
            kw = cw * 0.5; kh = ch * 0.5;
            
            sx = Math.floor(camx / cw);
            sy = Math.floor(camy / ch);
            ex = sx + 16 + 1;
            ey = sy + 16 + 1;
            sx -= 2;
            sy -= 2;
            
            //deb.text = " sx " + sx + " sy " + sy + " ex " + ex + " ey " + ey;
            deb.text = " pmx " + pic.mouseX + " pmy " + pic.mouseY;
            
            if (sy < 0) { sy = 0;}
            if (sy >= mheight) { return; }
            if (sx < 0) { sx = 0;}
            if (sx >= mwidth) { return;}
            
            if (ex < 0) { return; }
            if (ex > mwidth) { ex = mwidth;}
            if (ey < 0) { return; }
            if (ey > mheight) { ey = mheight; } 

            
            for ( i = sy; i < ey; i++)
            {
                yt = i * mwidth;
                
                for (k = sx; k < ex; k++)
                {
                     t = vecGrid[yt+k];
                     if (t < 0) { continue; }
            
                     rx = k * cw- camx;
                     ry = i * ch- camy;            
                     rz = 0;
                     
                     //if (t == 1) { rz = 16; } 
                    // rz = t;
                     
                    dx = rx - ry;
                    dy = (rx*0.5)+(ry*0.5) - rz;
                    
                    dx += 200;
                  //  dy += 100;
   
                    if (dx+cw < ax-cw) { continue; }
                    if (dy+ch < ay-ch) { continue; }
                    if (dx-cw > bx+cw+cw) { continue; }
                    if (dy-ch > by+ch) { continue; }
                    
            
                    c = vecCol[t];
                    
                   graphics.beginFill(c, 0.5);
                    graphics.moveTo(dx, dy);
                    graphics.lineTo(dx+cw,dy+kh);  
                    graphics.lineTo(dx+cw-cw,dy+kh+kh);
                    graphics.lineTo(dx-cw, dy+kh);
                    graphics.lineTo(dx,dy);
                   graphics.endFill();  
                   
                    
            
            
                }//nextk
                
            }//nexti
            
            
            graphics.drawRect(ax,ay,bx,by);
           
            //didnt bother to make a mask sprite 
            
            //(supposed to be 256px height, 
            //but i cant be bothered to figure out what went wrong)
            
            var aa:Number;
            
            aa = 0.95; //alpha
            
            graphics.beginFill(0, aa);
            graphics.drawRect(ax-64,ay,64, 256+64);
            graphics.endFill();
            
            graphics.beginFill(0, aa);
            graphics.drawRect(ax+256+64,ay,128, 256+64);
            graphics.endFill();
           
            graphics.beginFill(0, aa);
            graphics.drawRect(0,0, 512,64);
            graphics.endFill();
           
            graphics.beginFill(0, aa);
            graphics.drawRect(0,256+64+64, 512,64);
            graphics.endFill();
            
            
            
        }//onenter
        
    }//classend
}