/ Published in: ActionScript
- original by http://www.kirupa.com/developer/actionscript/grid.htm
- changes by me
- changes by me
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// GRID // ******************************************************************* // Set vars var num:Number; var numToReset:Number = 0; // Set function function setGrid():Void { // Reset Grid for (var r:Number = 0; r <= numToReset; r++) { removeMovieClip("grid"+r); } // Space between grids var xGridSpace:Number = 100; var yGridSpace:Number = 100; // Number of grids per axis var xGrids:Number = Math.ceil(Stage.width/xGridSpace); var yGrids:Number = Math.ceil(Stage.height/yGridSpace); // Number to increment num = 0; // X axis for (var i:Number = 0; i < xGrids; i++) { // Y axis for (var j:Number = 0; j < yGrids; j++) { grid_mc.duplicateMovieClip("grid"+num,num); mc=this["grid"+num]; mc._x = xGridSpace * i; mc._y = yGridSpace * j; mc._alpha = 50; mc.display_txt.text = num; num++; } } numToReset = num; // Hides master grid grid_mc._visible = false; } // RESIZE STAGE // ******************************************************************* // Create listener var resizeStage:Object = new Object(); // Detect resize resizeStage.onResize = function() { // Grid setGrid(); }