-
What's wrong with this code?
for (i=0;i<6;i++){
eval("newposition"+i) = eval("_rootosition"+i)
}
I am trying to create a variable and add "i" so that I don't have to write it out 6 times.
It keeps giving me this error message:
Symbol=controller, Layer=Layer 1, Frame=2: Line 3: Left side of assignment operator must be variable or property.
eval("newposition"+i) = eval("_rootosition"+i)
Isn't it a variable?
I'm just not great at hardcoding (if that's what you call it).
Appreciate any help
-
Try:
code:
for (i=0;i<6;i++){
this["newposition"+i]=_root["position"+i];
}
K.
-
try this:
code:
for(var i = 0; i < 6; i++){
_root["newposition" + i] = _root["position" + i];
}
oops, too late, hehe
-
Thanks for the replies.
I just want to understand, what is the difference between the square brackets from the normal or curly?
Also, I am trying to implement it to a property but it doesn't work. Any suggestions on the following?:
_root["box" + i + "._x"] = (this["newposition"+i]+(_root["box"+i+"._x"])) + 2;
-
[] = an array
all the items on the root timeline are stored as an array.
and your line should read:
Code:
_root["box" + i]._x = this["newposition" + i] + _root["box" + i]._x + 2;
-
Thanks, that worked perfect!
-
yw
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|