All pastes #784909 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-11-19 22:22 UTC
rendered paste body
package com.tomwademurphy.gui.grid {
	
	import flash.display.*;
	import flash.events.*;
	import fl.transitions.easing.*;
	import com.tomwademurphy.gui.grid.*;
	import com.tomwademurphy.anim.*;
  	
	
	public class GridExample extends AbstractGridModel {
		
		private var mMouseOverTransition:ITransition;
				
		public function GridExample() {
			
			super();
			
			// Pass mCells collection, Grid Size
			mGridDraw = new DrawStaticGrid(mCells, 5);	
			
			// Pass mContainer, mCells Collection, and ITransition
			mController = new GridController(mContainer, mCells, new FadeTransition(Strong.easeOut, 1));	
			
			// Define Mouse Over/Out Transition
			mMouseOverTransition = new ScaleTransition(Regular.easeOut, 0.1, 1.1);
						
			// Populate Cells
			addCells("box2", 20);
			
			// Start Column, Start Row, Column Count, Row Count			
			mController.setRegion(1, 1, 2, 3);
			
			// Graphic Frame
			drawMask(10); // Padding
			drawBorder(10, 1, 0x000000); // Padding, Thickness, Color, Alpha (Optional)			
						
		}
				
		protected override function instantiate(cell:GridCell):void {

			cell.setPadding(10, 10); // Column Padding, Row Padding
			cell.addEventListener(MouseEvent.MOUSE_OVER, cellMouseOver);
			cell.addEventListener(MouseEvent.MOUSE_OUT, cellMouseOut);

			super.instantiate(cell);

		}
		
		public function cellMouseOver(event:MouseEvent):void {
			mMouseOverTransition.transitionIn(event.currentTarget as Sprite);
		}
		
		public function cellMouseOut(event:MouseEvent):void {
			mMouseOverTransition.transitionOut(event.currentTarget as Sprite);
		}
		
	}
	
}