PDA

View Full Version : simple variables?



flipp
May 14th, 2005, 01:20 PM
FMX
Hello, I am trying to generate this line of code dynamicly...

movieclip.somefunction = b2._x;

and below is what I'm using...
movieclip.somefunction = ("b" + thisnum + "._x");

and I am storing a variable called thisnum. My line of code seems to return the correct value when I 'trace' it, but will not call the function correctly. Anyone see a problem? thanks in advance.

Flipp

Riddler?
May 14th, 2005, 01:25 PM
ahh this is because in example one you are giving movieclip.somefunction the value of:
(instance)b2.(variable)_x but in example two you are giving it the value STRING(b2._x).. you need to use associative programing like this:

movieclip.somefunction = _root["b"+thisnum]._x

or whatever other target is needed. ex:

_root.whatever["b"+thisnum]._x

i think you'll get the idea though

flipp
May 14th, 2005, 01:30 PM
Man thanks alot. I dont have a programming background so I'm kind of hacking around but that fixed my problem, and I think I understand what I was doing wrong. Thank you very.


ahh this is because in example one you are giving movieclip.somefunction the value of:
(instance)b2.(variable)_x but in example two you are giving it the value STRING(b2._x).. you need to use associative programing like this:

movieclip.somefunction = _root["b"+thisnum]._x

or whatever other target is needed. ex:

_root.whatever["b"+thisnum]._x

i think you'll get the idea though