Fullscreen Grid


/ Published in: ActionScript
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. // GRID
  2. // *******************************************************************
  3.  
  4. // Set vars
  5. var num:Number;
  6. var numToReset:Number = 0;
  7.  
  8. // Set function
  9. function setGrid():Void
  10. {
  11. // Reset Grid
  12. for (var r:Number = 0; r <= numToReset; r++)
  13. {
  14. removeMovieClip("grid"+r);
  15. }
  16.  
  17. // Space between grids
  18. var xGridSpace:Number = 100;
  19. var yGridSpace:Number = 100;
  20.  
  21. // Number of grids per axis
  22. var xGrids:Number = Math.ceil(Stage.width/xGridSpace);
  23. var yGrids:Number = Math.ceil(Stage.height/yGridSpace);
  24.  
  25. // Number to increment
  26. num = 0;
  27.  
  28. // X axis
  29. for (var i:Number = 0; i < xGrids; i++)
  30. {
  31. // Y axis
  32. for (var j:Number = 0; j < yGrids; j++)
  33. {
  34. grid_mc.duplicateMovieClip("grid"+num,num);
  35. mc=this["grid"+num];
  36. mc._x = xGridSpace * i;
  37. mc._y = yGridSpace * j;
  38. mc._alpha = 50;
  39. mc.display_txt.text = num;
  40. num++;
  41. }
  42. }
  43.  
  44. numToReset = num;
  45.  
  46. // Hides master grid
  47. grid_mc._visible = false;
  48. }
  49.  
  50.  
  51. // RESIZE STAGE
  52. // *******************************************************************
  53.  
  54. // Create listener
  55. var resizeStage:Object = new Object();
  56.  
  57. // Detect resize
  58. resizeStage.onResize = function()
  59. {
  60. // Grid
  61. setGrid();
  62. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.