Flash instance Q
- Started
- Last post
- 7 Responses
- ganon
i am attaching a series of MCs using a custom function...why wont my repositioning of the clips work in this function...:
function addSquare() {
if (current (lessThan) itemMax) {
attachMovie ("dot", "dot_mc" + current, current);
//xPos
this["dot_mc" + current]._x = startX + (current * offset);
//this is ok
trace (["dot_mc" + current] + " instance");
//so why does is this undefined???
trace (["dot_mc" + current]._x);
//yPos
this["dot_mc" + current]._y = startY;
current++;
} else {
trace("done");
}
}this turns up undefined
["dot_mc" + current]._x
whats wrong here...?
- jkosoy0
what happens when you change attachMovie to _level0.attachMovie?
just a thought.
- ganon0
thanks jamie, but that doesnt change anything....
- Mick0
"this" in your instance is referring to the function not the timeline isn't it? Your MC is on the timeline, not inside the function.
Also be careful with square bracket notation on the left
try something like this...
test = ["dot_mc" + current];
trace (_root[test]._x);
- ganon0
i took out the "this"s no change...but assigning it to a variable works, thanks a lot yo...!
- nospacebar0
Out of curiosity, what version of Flash are you using?
- londonBoy0
function addSquare() {
for (var i = current; i < itemMax; i++) {
dot = attachMovie("dot", "dot_mc" + i, i);
dot._x = startX + (i * offset);
dot._y = startY;
}
}
- ganon0
flash MX