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

Strangely Attracted

Based on strange attractor equation, with 1250 variances.
Get Adobe Flash player
by James.Merrill 30 May 2012
    Embed
package 
{

    import flash.display.MovieClip;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.events.Event;
    import flash.filters.BlurFilter;
    import flash.geom.Point;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.display.StageQuality;


    public class index extends MovieClip
    {
        private var _path:MovieClip;
        private var P_COUNT:int = 1250//1500;
        private var sW:int;
        private var sH:int;
        private var _buffer:BitmapData;
        private var _canvas:BitmapData;
        //private var _blur:BlurFilter = new BlurFilter(1.04,1.04,1);
        private var _blur:BlurFilter = new BlurFilter(30,30,1);
        private var drawCanvas:Sprite = new Sprite();
        private var mc_ar:Array = new Array();
        private var step:int = 0;
        private var mX:int;
        private var mY:int;
        //private var lastPoint:Point = new Point(0,0);
        public function index()
        {
            _path = this;
            stage.quality = StageQuality.LOW;
            sW = _path.stage.stageWidth;
            sH = _path.stage.stageHeight;
            _buffer = new BitmapData(sW,sH,true,0x000000);
            _canvas = new BitmapData(sW,sH,true,0x000000);
            var bit:Bitmap = new Bitmap(_canvas,"auto",true);
            addChild(bit);
            initPoints();
            _path.addEventListener(Event.ENTER_FRAME,update);
            _path.stage.addEventListener(MouseEvent.MOUSE_MOVE,setMouse);
        }
        private function setMouse(e:MouseEvent)
        {
            mX = _path.stage.mouseX;
            mY = _path.stage.mouseY;
            //trace(mX,mY);
        }
        private var lp_ar:Array = new Array();
        private function initPoints()
        {
            //lastPoint.x = _path.stage.mouseX
            //lastPoint.y = _path.stage.mouseY;
            for(var i = 0; i<P_COUNT; i++)
            {
            
                var d = i/P_COUNT;
               lp_ar.push(
                  [new Point(sW/2,sH/2), //lastPoint 0
                   500*d,     //P 1
                   130-(100*d),     //R 2
                   10/d,    //B 3
                   (.006*d),//.0042,   //D 4
                   Math.cos(i*Math.PI/11140), //M 5
                   10*d, //_x 6
                   10*d, //_y 7
                   1, //_z 8
                   i, //dx 9
                   1, //dy 10
                   0 //dz 11
                  ]);
                
            }
        }
        
        private var P:Number = 11;
        private var R:Number = 28;
        private var B:Number = 8 / 3;
        private var D:Number = 0.005;
        private var SCALE:int = 1;
        private var M:Number =  Math.cos(75*Math.PI/180)
        private var _x:Number = 0.1;
        private var _y:Number = 0;
        private var _z:Number = 0;
        private var dx:Number;
        private var dy:Number;
        private var dz:Number;
        private var tX:int;
        private var tY:int;
        private var d:Number;
        private var CC;
        private var color = 0x00FFDB;
        private function update(e:Event)
        {
            //if(l>5 || l<.1) ld*=-1;
            //l+=ld;
            //var zX = 1-((sW/2)-mX)/sW
            //var zY = 1-((sH/2)-mY)/sH
            mX = sW/2;
            mY = sH/2;
            for(var i = 0; i<P_COUNT; i++)
            {
                lp_ar[i][9] = lp_ar[i][1] * (lp_ar[i][7] - lp_ar[i][6]); //dx = p * (_y - _x);
                lp_ar[i][10] = lp_ar[i][6] * (lp_ar[i][2] - lp_ar[i][8]) - lp_ar[i][7]; //dy = _x * (R - _z) - _y;
                lp_ar[i][11] = lp_ar[i][6] * lp_ar[i][7] - lp_ar[i][3] * lp_ar[i][8]
                lp_ar[i][6] += lp_ar[i][4] * lp_ar[i][9]
                lp_ar[i][7] += lp_ar[i][4] * lp_ar[i][10]
                lp_ar[i][8] += lp_ar[i][4] * lp_ar[i][11]
                
                //drawCanvas.graphics.lineStyle(1,0xFF0000+i);
                d = i/P_COUNT;
                CC = color //-(0xFFF*d);
                drawCanvas.graphics.lineStyle(1,CC,.8*d + .2);
                tX = lp_ar[i][0].x + (mX-lp_ar[i][0].x)/1     +(((lp_ar[i][6] * SCALE)))
                tY = lp_ar[i][0].y + (mY-lp_ar[i][0].y)/1     +((lp_ar[i][7] * lp_ar[i][5] + lp_ar[i][8]))* SCALE //- 300
                
                //if(tX > sW || tX < 0 || tY > sH || tY < 0) lp_ar[i][9] = lp_ar[i][9] = lp_ar[i][10] = lp_ar[i][11] = 1;
                
                drawCanvas.graphics.moveTo(lp_ar[i][0].x, lp_ar[i][0].y);
                drawCanvas.graphics.lineTo(tX, tY);
                lp_ar[i][0].x = tX;
                lp_ar[i][0].y = tY;
                
                
                /*
                var p = P +i;
                var s = D;
                var sD = SCALE//(i+1);
                
                dx = p * (_y - _x)/zX;
                dy = _x * (R - _z) - _y;
                dz = _x * _y - B * _z;
                _x += s * dx;
                _y += s * dy;
                _z += s * dz;
                var lastPoint = lp_ar[i];
                drawCanvas.graphics.lineStyle(P_COUNT-i+1,0x00FFFF*step);
                //tX = sW/2 + (_x * sD) +(200/(i+1))
                //tY = sH/2 +200 -(_y * M + _z) * sD
                tX = lastPoint.x + (mX-lastPoint.x)/10 +(((_x * sD)/(i+1)));
                tY = lastPoint.y + (mY-lastPoint.y-200)/10 +((_y * M + _z)/(i+1))* sD
                trace(tX,tY);
                drawCanvas.graphics.moveTo(lastPoint.x, lastPoint.y);
                drawCanvas.graphics.lineTo(tX, tY);
                lastPoint.x = tX;
                lastPoint.y = tY;
                */
            }
            //canvas.graphics.lineTo(_x * SCALE, -(_y * M + _z) * SCALE);
                
            /*for(var i = 0; i<P_COUNT; i++)
            {
                
                
                drawCanvas.graphics.lineStyle(2,i*(0x00FFFF));
                var p:Array = mc_ar[i];
                var r = 10+((P_COUNT/i)*2);
                //var oS = 100+(((sW/2)-50)/P_COUNT)*1;
                var oS = i;
                //var tX:int = mX+(Math.cos(step/r)*oS) + (Math.sin(step/r)*zX*50);
                //var tY:int = mY+(Math.sin(step/r)*(i*2)) + (Math.cos(step/r)*zY*50);
                //tX = sW/2 + (Math.cos(step/r)*oS/zX)
                //tY = sH/2 + (Math.sin(step/r)*(oS/zY))
                tX = sW/2 - (Math.cos(step/r)*(oS))
                tY = sH/2 - (Math.sin(step/r)*(oS)) 
                drawCanvas.graphics.moveTo(p[1].x,p[1].y); 
                drawCanvas.graphics.lineTo(tX,tY);
                //drawCanvas.graphics.lineTo(p[1].x + (tX - p[1].x)/10,p[1].y + (tY - p[1].y)/10);
                p[1] = new Point(tX,tY);
                
            }*/
            step++;
            color--
            /*
            drawCanvas.graphics.lineStyle(10,0x000000);
            drawCanvas.graphics.moveTo(lastPoint.x,lastPoint.y);
            drawCanvas.graphics.lineTo(_path.stage.mouseX,_path.stage.mouseY);
            lastPoint.x = _path.stage.mouseX
            lastPoint.y = _path.stage.mouseY;
            */
            drawIt();
            drawCanvas.graphics.clear();
        }
        private var fadeStep = 0;
        private var fadeMax = 2;
        private function drawIt()
        {
            //_buffer.fillRect(_buffer.rect,0x0F000000);
            //_buffer.fillRect(_buffer.rect,0x10000000);
            fadeStep++
            if(fadeStep > fadeMax)
            {
                fadeStep = 0;
                //_buffer.fillRect(_buffer.rect,0x00000000);
                trace("s");
            }
            _buffer.fillRect(_buffer.rect,0x0A000000);
            _buffer.draw(drawCanvas);
            _canvas.applyFilter(_canvas,_buffer.rect,new Point(0,0),_blur);
            _canvas.draw(_buffer);
        }
    }

}