Intermediate Flash Help

  • Started
  • Last post
  • 3 Responses
  • nosaj

    I'm having trouble getting the value of a variable called from concatenated string. Here's the code:

    n = random(Number(5));
    // I pick a random number.

    _level0.dis = ("_level0.clip"+n);
    // I then concatenate a a string with the random number on the end of the string

    _level0.thetext = _level0.dis;
    // I then set a variable to the value of the newly concatenated variable. This is where the problems arises. _level0.dis seems to equal to the concatinated variable as a string as opposed to grabing the value fo that string.

    ie.
    _level0.text holds a value of _level0.clip3, as opposed to the value of _level0.clip3 which is "Hello I'm Clip 3". If I call _level0.clip3 directly then I get the proper value.

    I hope this makes a little bit of sense... Any help would be greatly appreciated.

  • E0

    probably you want to get the name of the movieclip or something, by calling the MC or Object itself you will get a reference to that object and not a value within that object - you need to specify the value you want to grab from that object.

    var str = _root[obj]._name

    this will give you the name of the object.

    random(5) is ok, you don't have to make it a number object first

    ("level0.clip"+n) won't give you an object, but a string -
    level0 or _root["clip"+n] will give you an object

    I hope this will help you a bit

    Good luck

  • nosaj0

    E - thanks!

    The problem was "("level0.clip"+n) won't give you an object, but a string -
    level0 or _root["clip"+n] will give you an object "

    Thanks for taking the time. I had a bad feeling I was going to be raking my brain all day over this...

  • E0

    It's alright, no thanks

    good luck