Return to Snippet

Revision: 29822
at August 5, 2010 00:41 by adamcoulombe


Updated Code
// Demo for this example at http://adamcoulombe.info/lab/as3/gridlayout.html

//Download these classes at http://www.greensock.com/tweenlite/
import com.greensock.TweenLite; 
import com.greensock.easing.*;




var gridItems = new Array();
var grid = new Sprite();
grid.x = 65;
grid.y = 50;
addChild(grid);

for (var i:int = 0; i < 20; i++) {
	gridItems[i] = new MyBox();
	gridItems[i].x = (i % 5) * (gridItems[i].width );
	gridItems[i].y = int(i / 5) * (gridItems[i].height);
	gridItems[i].addEventListener(MouseEvent.MOUSE_OVER,gridItemOver);
	gridItems[i].addEventListener(MouseEvent.MOUSE_OUT,gridItemOut);
	grid.addChild(gridItems[i]);
}
function gridItemOver(e){
	grid.addChild(e.currentTarget);
	TweenLite.to(e.currentTarget,0.5,{scaleX:1.2, scaleY:1.2,ease:Elastic.easeOut});
}
function gridItemOut(e){
	TweenLite.to(e.currentTarget,0.5,{scaleX:1, scaleY:1,ease:Elastic.easeOut});
}

Revision: 29821
at August 5, 2010 00:07 by adamcoulombe


Initial Code
import com.greensock.TweenLite;
import com.greensock.easing.*;

var gridItems = new Array();
var grid = new Sprite();
grid.x = 65;
grid.y = 50;
addChild(grid);

for (var i:int = 0; i < 20; i++) {
	gridItems[i] = new MyBox();
	gridItems[i].x = (i % 5) * (gridItems[i].width );
	gridItems[i].y = int(i / 5) * (gridItems[i].height);
	gridItems[i].addEventListener(MouseEvent.MOUSE_OVER,gridItemOver);
	gridItems[i].addEventListener(MouseEvent.MOUSE_OUT,gridItemOut);
	grid.addChild(gridItems[i]);
}
function gridItemOver(e){
	grid.addChild(e.currentTarget);
	TweenLite.to(e.currentTarget,0.5,{scaleX:1.2, scaleY:1.2,ease:Elastic.easeOut});
}
function gridItemOut(e){
	TweenLite.to(e.currentTarget,0.5,{scaleX:1, scaleY:1,ease:Elastic.easeOut});
}

Initial URL
http://adamcoulombe.info/lab/as3/gridlayout.html

Initial Description
Simple grid layout technique in actionscript 3. Check out the demo and more details at http://adamcoulombe.info/lab/as3/gridlayout.html

Initial Title
AS3 Simple Grid Layout

Initial Tags
actionscript, flash, layout

Initial Language
ActionScript 3