| Flashscript classes (ActionScript 3) | Home | MX | MX 2004 | Flash 8 | Flash 9 |Flash 10 |PHP |Components | Snippets | Contact | |
GridMaker |
|
|
| Method | Defined By |
|---|---|
|
GridMaker()
Creates a new instance of the GridMaker class. |
GridMaker |
|
makeGrid(_target:Object, nameClass:String, nameClip:Object, _lastRow:int, _lastCell:int, _addFunction:Function=null, _xDistance:int=0, _yDistance:int=0,
_xAddition:int=0, _yAddition:int=0)
Initiates creating the grid. |
GridMaker |
|
arrangeGrid(myArray:Array, _lastRow:int, _lastCell:int, _addFunction:Function=null, _xDistance:int=0, _yDistance:int=0, _xAddition:int=0, _yAddition:int=0)
Will create a grid from existing objects, which are collected in an array. |
GridMaker |
| Constructor Detail |
|---|
|
GridMaker () Constructor
public function GridMaker() |
| Intializes a new GridMaker instance. |
| Method Detail |
|---|
|
makeGrid() method
This method will initiate creating the grid. |
Parameters
|
|
arrangeGrid() method
Will create a grid from existing objects, which are collected in an array. |
Parameters
|
| Examples |
|---|
Create a new fla file and name it GridMaker.fla. Place the fla in the same folder as the biz folder. Create two MovieClips one with the identifier Circle and the other with the identifier Square. Export to actionscript. Then create an Actionscript file, name it Gridmaker.as and place this script.
package
{
import flash.display.Sprite;
import flash.display.MovieClip;
import biz.flashscript.displayobjects.GridMaker;
public class Gridmaker extends Sprite
{
public function Gridmaker ():void
{
var cm:GridMaker=new GridMaker();
var mc:Sprite;
/*
* Creating squares, adding a function to it allows
* further manipulation of the Grid. Here the function
* is to remove a square on mouse click.
*/
var _target:Object = this;
var _className = "Square";
var _nameClip:Object = mc;
var lastRow:int = 5;
var lastCell:int = 4;
var xD:int = 55;
var yD:int = 55;
var xAdd:int = 10;
var yAdd:int = 10;
var functionname:Function = mcFunction;
cm.makeGrid (_target, _className, _nameClip, 5, 4, functionname, xD, yD, xAdd, yAdd);
/*
* Creating circles. This function simply arranges a custom grid.
*/
var _mc:Circle;
var myArray:Array=new Array();
for (var i=0; i<=20; i++)
{
mc=new Circle();
myArray.push (mc);
addChild (mc);
}
cm.arrangeGrid (myArray, 5, 5, 250, 10);
}
private function mcFunction (mc):void
{
trace (mc.id);
trace (mc.name);
mc.parent.removeChild (mc);
}
}
}
|