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

matrix 5*5

Get Adobe Flash player
by keiso 26 Apr 2009
package
{
	import caurina.transitions.Tweener;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	[SWF(width="465", height="465",backgroundColor="#000000",frameRate="30")]  
	
	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()
		{
			tf = new TextField();
			tf.text = "Hello world";
			tf.textColor = 0xffffff;
			this.addChild(tf);
			
			g = new MovieClip();
			this.addChild(g);
			
			for(var i:int=0;i< numOfCircle;i++){
				mc = new MovieClip();
				
				mc.graphics.clear();
				mc.graphics.beginFill(0xff0000);
				mc.graphics.drawCircle(0,0,25);
				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.5);

			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"});
			}
			
		}
	}
}