forked from: flash on 2010-7-18

by hacker_szoe51ih forked from flash on 2010-7-18 (diff: 67)
♥0 | Line 85 | Modified 2010-07-19 15:13:32 | MIT License
play

ActionScript3 source code

/**
 * Copyright hacker_szoe51ih ( http://wonderfl.net/user/hacker_szoe51ih )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/qZmD
 */

// forked from hacker_szoe51ih's flash on 2010-7-18
package {
    import flash.geom.*;
    import flash.filters.*;
    import flash.display.AVM1Movie;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.geom.PerspectiveProjection;
    import flash.display.*;
    public class Perspective extends MovieClip {

        public var p:Particle;
        public var dropFilter:DropShadowFilter;
        public var blurFilter:BlurFilter;
        public var W:Number = stage.stageWidth;
        public var H:Number = stage.stageHeight;
        
        public var parent1:MovieClip;
        public var parent2:MovieClip;
        
        public var centerX:Number = W / 2;
        public var centerY:Number = H / 2;
        public var pArray:Array;
        public var pArray2:Array;
        public var filterArray:Array;
        public var filterArray2:Array;
        public var atPerspectiveProjection:PerspectiveProjection;
        public var atFieldOfView:Number;


        public function Perspective() {

            pArray=new Array();
            pArray2=new Array();
            
            filterArray=new Array();
             filterArray2=new Array();
            dropFilter=new DropShadowFilter(20,120,0x999999,0.7,7,7);
            

            atPerspectiveProjection = root.transform.perspectiveProjection;
            atFieldOfView = atPerspectiveProjection.fieldOfView;
               
             parent1=new MovieClip();
             parent2=new MovieClip();    
            
            for (var i:int=0; i<6; i++) {
                
                
                p = new Particle(Math.random() * 0xffffff,50);
                
                
                
                p.x = centerX;
                p.y = centerY;
                p.z=i*20
                
                filterArray=p.filters;
                blurFilter=new BlurFilter(p.z*0.01,p.z*0.01,2);
                filterArray.push(blurFilter);
                

                pArray.push(p);
                parent1.addChild(pArray[i]);
               
             

            }
            
            for (i=0; i<6; i++) {
            p = new Particle(Math.random() * 0xffffff,50);
                
                
                p.x = centerX;
                p.y = centerY;
                p.z=i*20
                
                filterArray2=p.filters;
                blurFilter=new BlurFilter(5,5,2);
                filterArray2.push(blurFilter);
                

                pArray2.push(p);
                parent2.addChild(pArray2[i]);
                
             }  
            
            addChild(parent1);
            parent1.y=centerY-400;
            addChild(parent2);
            parent2.y=centerY-100;
          
            
            
         

            stage.addEventListener(MouseEvent.CLICK,onClick);
            
            stage.addEventListener(Event.ENTER_FRAME,enterframer);

        }

        public function enterframer(e:Event):void {
            atPerspectiveProjection.projectionCenter = new Point(mouseX,mouseY);
            /*var newFieldOfView:Number=0;
            newFieldOfView=170;
            atFieldOfView = Math.max(Math.min(179,newFieldOfView),1);*/
            


            trace("atPerspectiveProjection.projectionCenter.x=="+atPerspectiveProjection.projectionCenter.x);
            trace("atFieldOfView=="+atFieldOfView);
        }
        
        public function onClick(e:MouseEvent):void{
        
            atPerspectiveProjection.focalLength = Math.floor(Math.random() * 180) + 1;
        
        }





    }
}

import flash.display.*;
class Particle extends Sprite {

    public var p:Sprite;

    public function Particle(col:uint,r:Number):void {

        p=new Sprite();
        p.graphics.beginFill(col);
        p.graphics.lineStyle();
        p.graphics.drawCircle(0,0,r);
        p.graphics.endFill();
        addChild(p);

    }
}