/ Published in: ActionScript 3
Simple grid layout technique in actionscript 3. Check out the demo and more details at http://adamcoulombe.info/lab/as3/gridlayout.html
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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}); }
URL: http://adamcoulombe.info/lab/as3/gridlayout.html