Return to Snippet

Revision: 4593
at January 13, 2008 11:52 by imhugo


Updated Code
// 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();
}

Revision: 4592
at January 13, 2008 10:34 by imhugo


Updated Code
// GRID
// *********************************************************

// Space between grids
// to use in a pattern, this are the symbol's dimensions
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.width/yGridSpace);

// Number to use in levels and duplicate
var num:Number = 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;
    num++;
  }
}

// Hides master grid
grid_mc._visible = false;

Revision: 4591
at January 13, 2008 09:54 by imhugo


Updated Code
// Space between dots
gridx=30;
gridy=30;
// Number of dots per axis
dotsx=10;
dotsy=10;
// Number to increment
num=0;

// X axis
for (var i=0;i < dotsx;i++)
{
  // Y axis
  for (var j=0;j < dotsy;j++)
  {
    dot.duplicateMovieClip("dot"+num,num);
    mc=this["dot"+num];
    mc._x=gridx*i;
    mc._y=gridy*j;
    num++;
  }
}
// Hides master dot
dot._visible=0;

Revision: 4590
at January 13, 2008 09:52 by imhugo


Initial Code
// Space between dots
gridx=30;
gridy=30;
// Number to increment
num=0;

// X axis
for (var i=0;i < 10;i++)
{
  // Y axis
  for (var j=0;j < 10;j++)
  {
    dot.duplicateMovieClip("dot"+num,num);
    mc=this["dot"+num];
    mc._x=gridx*i;
    mc._y=gridy*j;
    num++;
  }
}
// Hides master dot
dot._visible=0;

Initial URL

                                

Initial Description
- original by http://www.kirupa.com/developer/actionscript/grid.htm
- changes by me

Initial Title
Fullscreen Grid

Initial Tags

                                

Initial Language
ActionScript