Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: var dynamic

  1. #1
    New Coder
    Join Date
    Nov 2008
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts

    var dynamic

    hey
    i cant seem to get this working:

    i want to trace "dang!"
    AS2

    Code:
    imgNumb = 1;
    newi = imgNumb.toString();
    _root.myData.image1 = "dang!";
    imageName = ["_root.myData.image" + newi];
    trace(imageName);
    all i get is "_root.myData.image1"

    any ideas?
    Last edited by ricmetal; 12-10-2008 at 08:47 PM.

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Code:
    imageName = [_root.myData.image + newi];
    Well quotes turn that into a string, and not into a reference to an item. Does this work?
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #3
    New Coder
    Join Date
    Nov 2008
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts
    it might, i just found out that tracing _root.myData.image1 yields undefined.
    *what?*
    any idea why this happens?
    it's the only script i have on the fla

  • #4
    New Coder
    Join Date
    Nov 2008
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts
    duh, there no myData
    ...

  • #5
    New Coder
    Join Date
    Nov 2008
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jeremywilken View Post
    Code:
    imageName = [_root.myData.image + newi];
    Well quotes turn that into a string, and not into a reference to an item. Does this work?
    no, that doesn't work

  • #6
    New Coder
    Join Date
    Nov 2008
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts
    got it
    Code:
    imgNumb = 1;
    newi = imgNumb.toString();
    _root.myData.image1 = "dang!";
    imageName = eval("_root.myData.image" + newi);
    trace(imageName);
    Last edited by ricmetal; 12-10-2008 at 09:44 PM.


  •  

    Posting Permissions

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