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

ff: ff: matrix 5*5

Get Adobe Flash player
by tel-dot 30 Jul 2011
    Embed
/**
 * Copyright tel-dot ( http://wonderfl.net/user/tel-dot )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rITg
 */

// forked from keiso's matrix 5*5
package {
    import flash.display.*;
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    
    import caurina.transitions.Tweener;
    
    [SWF(width="465", height="465",backgroundColor="#000000",frameRate="50")]  
    
    public class Matrix55 extends Sprite {
        private var mc:MovieClip;
        private var g:MovieClip;
        
        private var tf:TextField;
        
        private var numOfCircle:uint = 25;
        
        private var circleWidth:uint = 77;
        private var circleHeight:uint = 77;
        private var circleOffset:uint = 77;
        
        public function Matrix55() {
                        var colourArray:Array = [0xE81000,0xFFCA09,0xFF0232,0x001AE8,0x09FF41,0xffffff*Math.random()];

            tf = new TextField();
            tf.text = "Hello world";
            tf.textColor = 0xffffff;
            addChild(tf);
            
            g = new MovieClip();
            addChild(g);
            
            for(var i:int=0;i< numOfCircle;i++){
                mc = new MovieClip();
                
                mc.graphics.clear();
                mc.graphics.beginFill(colourArray[Math.round(Math.random()*5)]);
                mc.graphics.drawRect(-25, -25, 50, 50);
                mc.graphics.endFill();
                mc.x = circleWidth * (i % 5) + circleOffset;
                mc.y = circleHeight * Math.round(i / 5 -0.5) + circleOffset;
                
                g.addChild(mc);
            }
            
            g.addEventListener(MouseEvent.MOUSE_OVER,onMouseOverHandler);
            g.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler);
        }
        
        private function onMouseOverHandler(e:MouseEvent):void {
            var target:MovieClip = e.target as MovieClip;
            var index:int = g.getChildIndex(target);
            tf.text = index.toString();
            
            aroundBehavior(index,1.2);

            Tweener.addTween(e.target, {
                 scaleX:1.8, scaleY:1.8,
                 time:0.5,
                 transition:"easeOutCubic"
              });            
        }
        private function onMouseOutHandler(e:MouseEvent):void {
            var target:MovieClip = e.target as MovieClip;
            var index:int = g.getChildIndex(target);
            tf.text = index.toString();

            aroundBehavior(index,1);

            
            Tweener.addTween(e.target, {
                 scaleX:1, scaleY:1,
                 time:0.5,
                 transition:"easeOutCubic"
              });            
        }
        private function aroundBehavior(index:int,scale:Number):void{
            if(index % 5 != 0){
                Tweener.addTween(g.getChildAt(index-1), {scaleX:scale, scaleY:scale,time:0.5,transition:"easeOutCubic"});
            }
            if(index > 4){
                Tweener.addTween(g.getChildAt(index-5), {scaleX:scale, scaleY:scale,time:0.5,transition:"easeOutCubic"});
            }
            if(index % 5 != 4){
                Tweener.addTween(g.getChildAt(index+1), {scaleX:scale, scaleY:scale,time:0.5,transition:"easeOutCubic"});
            }
            if(index < numOfCircle -5){
                Tweener.addTween(g.getChildAt(index+5), {scaleX:scale, scaleY:scale,time:0.5,transition:"easeOutCubic"});
            }
            
        }
    }
}