Groups | Blog | Home
all groups > flash actionscript > may 2004 >

flash actionscript : Colons in actionscript??



B
5/22/2004 7:00:10 PM
I found some script on the internet that uses the attachMovie method to create
a tiled background effect and I don't understand one of the lines that uses
colons. If someone could explain to me what that's all about then I would
really appreciate it. Here's the code:

numCols = Stage.width/10;
numRows = Stage.height/10;

cnt = 1;

for(var i=0;i<numRows;i++) {
for(var j=0;j<numCols;j++) {

tmpObj = {_x:startX,_y:startY};//*****THIS IS THE LINE I DON'T UNDERSTAND.
For the most part I get what
// it's doing but I don't get why it's written that way as I've never seen the
use of colons in actionscript before*****

thisClip = _root.attachMovie("myClip", "mc"+cnt, cnt, tmpObj);

cnt++;

startX += thisClip._width*4;
trace(startX)
}
startX = 0;
startY += thisClip._height*4;
}
Jack.
5/22/2004 7:59:51 PM
the colons are used to set values within an object (also used in arrays).
make use of List Variables to see how Flash interprets your code,

startX = startY = 50;
tmpObj = {_x:startX,_y:startY};
/* _level0.tmpObj = [object #1, class 'Object'] {
_y:50,
_x:50
} */

aDP = [];
aDp[0] = {label:"Zero",data:0}
aDp[1] = {label:"One",data:1}
/* _level0.aDP = [object #2, class 'Array'] [
0:[object #3, class 'Object'] {
data:0,
label:"Zero"
},
1:[object #4, class 'Object'] {
data:1,
label:"One"
}
] */

hth


B
5/22/2004 11:02:52 PM
Thank you... I understand now.

AddThis Social Bookmark Button