dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: dynamically creating variable name

  1. #1
    Junior Member
    Join Date
    Jun 2002
    Posts
    10
    Greetings All,

    I just want to be able to dynamically create a variable name.

    The syntax I was thinking should work is:
    eval("op"+maxvar) = JobName;
    which should translate to
    op1 = JobName
    where
    maxvar = 1

    however it doesn't work. Any suggestions would be greatly appreciated!

    Thanx,
    Zitan

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Posts
    106

    there is a syntax error

    hi zitan,

    In FlashMX eval() cannot be used in the LHS as you did. In flash 5 you can do that. just say ctrl+t in you action script place, you will find error message.....

    Technology upgrades but functionality downgrades )

    good luck
    gnana

  3. #3
    Tai'shar Manetheren! skierbit's Avatar
    Join Date
    Dec 2000
    Location
    Provo, Utah
    Posts
    407
    The set command is one, in the a
    ctionScipt reference in MX and the AS Dictionary if you want further material on it, but pretty much the first group before the , is the variable name and then the second part is what it is equal to, just another way to set variable names, but I like it becuase it can do it dynamically!

    Code:
    maxVar = 1;
    set("op" + maxVar, jobName);
    trace(eval("op" + maxVar));
    Happy Flashing!

  4. #4
    Junior Member
    Join Date
    Jun 2002
    Posts
    10

    Smile

    Thanks that totally works, set is the way to go here. That rocks. Now if I could just work out how to pass variables into flash when I open the movie (like the username) I'd be all sorted

    Thanks again you guys rock

    Z.

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