A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Creating variable dynamically

  1. #1
    Junior Member
    Join Date
    Oct 2000
    Posts
    14

    Creating variable dynamically

    Hello,

    I want to produce a variable dynamically and store a value in it.

    I'm using:

    eval("_root."+main+"_sub1") = sub1 - 1;

    But it is producing an error:

    Left side of assignment operator must be variable or property.

    Any ideas?

    Thanks in advance

  2. #2
    Senior Member
    Join Date
    Apr 2000
    Location
    Northern Ireland
    Posts
    2,146
    Try:

    _root[main + "_sub1"] = sub1 - 1;
    ----------
    "Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." TERRY PRATCHETT

  3. #3
    Junior Member
    Join Date
    Oct 2000
    Posts
    14
    You complete genius!
    It worked first time.
    Thank you very much.
    I assume all that bracket "[" stuff is new in MX as I'm not familiar with it.

  4. #4
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    No, the _root[] stuff was around in flash 5. However in flash 5 you could also use eval as a left hand side but in MX Macromedia have removed this because it wasn't part of the ECMA standard actionscript is based on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center