While reading a tutorial about movieclips, textfields, and Drawing API, one of the instructions was to write this code:
var linkageArr:Array = ["A", "B", "C", "D", "E", "F", "A", "B", "C", "D", "E", "F"];
var clips:Object = new Object();
var clip:MovieClip;
for(var i:Number = 0; i < linkageArr.length; i++)
{
depth = this.getNextHighestDepth();
clip = this.attachMovie(linkageArr*, "clip" + depth, depth, {_x: x, _y: y});
//drawRectangle function creates a filled rectangle and returns a movie clip
card = drawRectangle(Math.random() * 0xFFFFFF, clip._width, clip._height, x, y);
**clips[card._name] = {id: linkageArr*, clip: clip};**
}
function drawRectangle(color:Number, width:Number, height:Number, x:Number, y:Number): MovieClip
{
var depth:Number = this.getNextHighestDepth();
var clip:MovieClip;
clip = this.createEmptyMovieClip("clip" + depth, depth);
clip.lineStyle(0, 0, 0);
clip.beginFill(color);
clip.lineTo(width, 0);
clip.lineTo(width, height);
clip.lineTo(0, height);
clip.lineTo(0, 0);
clip.endFill();
clip._x = x;
clip._y = y;
return clip;
}
[COLOR=Cyan]clips[[/COLOR][COLOR=Black]card._name[/COLOR][COLOR=Cyan]][/COLOR] = {[COLOR=Blue]id[/COLOR]: linkageArr*, [COLOR=Blue]clip[/COLOR]: clip};
Now my problem is, just when did I every declare an [COLOR=Cyan]object array named clips[/COLOR]? And why does Actionscript allow me to create [COLOR=Blue]variables that were never declared[/COLOR]?
I read the documentation of Objects but never dealt with what happens with the array. This question might sound a bit primitive because I mainly focusing on C++ so the syntax and implicit effects of Actionscript is unfamiliar to me.