A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Former Employee of Satan Napalm's Avatar
    Join Date
    May 2000
    Location
    Stellenbosch, South Africa
    Posts
    561

    Referencing dynamic variables

    I'm loading items from a MySQL dbase, and depending on the number of items it creates a number of menuitems (MC with a textfield).

    How do I populate the textfield (called Fieldname)? The eval pics up the value of the textfield, but I cant put a value in there.

    Code:
    _root.Numberof = _root.Numberof *1;
    for(i=0; i<_root.Numberof; i++) {
    //	_root.news +=eval("_root.MenuItem"+i);
    	duplicateMovieClip("ParentMenu", "Menu"+i, (i+1));
    	tempvar =eval("Menu"+i+".Fieldname");
    	tempvar = "test";
    	
    }
    Never underestimate the power of stupid people in large groups

  2. #2
    Senior Member
    Join Date
    Apr 2001
    Location
    UK
    Posts
    493
    ["Menu"+i].fieldName="hello"

    or absolute

    _root["Menu"+i].fieldName="hello"

    hoope its what your after

  3. #3
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,150
    I think you have to turn things arouns. TempVar is the value, isnt it?

    If the textfield is called fieldName you have to use that first.

    tempvar = "test";
    this["Menu"+i].fieldname=tempvar;

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  4. #4
    Former Employee of Satan Napalm's Avatar
    Join Date
    May 2000
    Location
    Stellenbosch, South Africa
    Posts
    561
    Thanks I've sorted it out:

    Code:
    set ("Menu"+i+".Fieldname", eval("MenuItem"+i));
    Never underestimate the power of stupid people in large groups

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