-
[MX] set("a"+i+"._x","b"+i+"._x") help.
As you can probably see by the title, I want to address the x of one to the x of another, the problem being that they are both dynamically named and called.
If I write
set("whatever"+i+"._x",400); // x goes to 400 no problems.
However if I write
set("whatever"+i+"._x","object"+i+"._x"); // it asumes that the second variable is just a string value and not the thing I want to call.
Can someone tell me how to set a1._x to b1._x dynamically, (preferably in a similar way to described above.)
-
Maybe try something like this...
Code:
whatever = "a";
otherone = "b";
i = 1;
eval(whatever + i)._x = eval(otherone + i)._x;
-
mess with this:
code:
var x;
var y = 12;
var myX12 = 7;
var mySpot = eval("myX"+y);
set('x',mySpot);
trace('x: '+ x);
stop();
i would take: object"+i+"._x and do this
var myNewObject = eval("object"+i+"._x");
set("whatever"+i+"._x",myNewObject); // no quotes
hope this helps
IMS
-
Flashmatics
use array notation and dot notation , (don't use set, that's old school) e.g
Code:
this["whatever"+i]._x = this["object"+i]._x;
-
silentWeed, I've been trying to use the array notation, but sometimes it doesn't seem to work as it should. I don't have an example of this problem now, but when it happens again, I'll be hitting you up.
IMS
-
Thanks Y'all, got it now....
believe it or not, I have used Flash for years and never come across the eval() function. Kinda funny realy.
set(eval("a"+i+"._x"),eval("b"+i+"._x"));
worked in the example that I gave in the title.
Thanks again.
-
Flashmatics
Originally Posted by IMS
silentWeed, I've been trying to use the array notation, but sometimes it doesn't seem to work as it should. I don't have an example of this problem now, but when it happens again, I'll be hitting you up.
IMS
Sure let me know when you encounter a problem using array notation
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
|