Actionscript: variable in target path

  • pavlo
  • Born
  • Born
  • pavlo
  • Posts: 2

Post 3+ Months Ago

Hi, I need some help with actionscript.

I have a variable , for example:

var str = "Myclip";

I need to change properties in MovieClip, ... this way:

_root.dropZone.str._x = "something";

The problem is, that when I type in this path the variable str, it doesn't work.
I must type it exactly so: _root.dropZone.Myclip._x = "something"; this way it
works perfectly, but this way i can't change the properties dinamically for many movieClips. That's the reason why i need to use a variable in target path.

my actionscript code is in first frame in movieClip dropZone.

Have you any idea how to solve this problem, or what i'm doing wrong.
If you need more info, i will write it.
thank's for help.

Pavlo
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • roarmeow
  • Professor
  • Professor
  • User avatar
  • Posts: 861
  • Loc: BKNY

Post 3+ Months Ago

yeah, definitely...

you should be putting in:
_root.dropZone[str]._x = "something";

because just putting _root.dropZone.str._x is going to interpret "str" as the string "str", it only knows it's a variable if you put it in the brackets.

wish i could explain it better, wish i had a link for you, but i totally forget how i learned that. hope it makes sense.

also, "something" is not a valid value for _x, because _x is the x coordinate.

if something is a variable, it should be without quotes in your code.
  • pavlo
  • Born
  • Born
  • pavlo
  • Posts: 2

Post 3+ Months Ago

thanks a lot for help, I will try it. I know that _x is the x coordinate, i type "something" just for ilustration in program i will set there a number of course.

Pavlo

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 8 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.