| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Risu Oyabun!
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
|
I'm trying to create a menu bar that dynamically creates content based on data found in an array declared on the root. The object that does this is a movie clip called listbox that contains another movie clip called item. Still with me? Okay, the item contains a dynamic text field and a button. The text field is tied to a variable called txt. It looks a bit like this:
root -> listbox -> item -> text field & button When the menu needs to be populated, it runs the following function that's written in the listbox movieclip: function populate(list) { var i; for (i = 1; i <= list.length; i++) { duplicateMovieClip("itm", "itm_" + i, i + 1); setProperty("itm_" + i, _x, 0); setProperty("itm_" + i, _y, 18.5 * i); set ("itm_" + i + ".txt", list[a-1]); } } The function runs through and dupes the movie clips, positioning them properly with setProperty. It does not set the txt variable, though... and it's drivin' me crazy trying to figure out WHY!!! I've tried changing the set statement to: ["itm_" + i].txt = list[a-1]; Alas, it was to no avail! Any thoughts, curses, comments on the matter would be _greatly_ appreciated. THANKS!!! [Edited by 20 Ton Squirrel on 04-30-2001 at 04:43 PM] |
|
|
|
|
|
#2 |
|
New Member
Join Date: Jan 2001
Posts: 245
|
If your array is on the root you need;
set ("itm_" + i + ".txt", _root.list[a-1]); or; eval("itm_"+i+"txt")=_root.list[a-1]; ~mgb |
|
|
|
|
|
|
|
|
#3 |
|
Risu Oyabun!
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
|
The script is actually a function that accepts an array as an argument. So the "populate" function is actually called from the root using the array as the argument. Should I really be referencing the variable back to the root? It's called like this...
who = new Array("Jay", "Silent Bob", "Dante Hicks"); listbox.populate(who); I know it gets the array correctly because it actually dupes the movie clips and places them correctly. Am I totally off base on this? Dazed and confused, Squirrel |
|
|
|
|
|
#4 |
|
New Member
Join Date: Jan 2001
Posts: 245
|
Ok I see what you are doing now. If your array is on the root you might be better to just use;
set ("_root.listbox.itm_" + i + ".txt"... = _root.who[a-1]; without sending the argument to it. N.B. should itm not be item? ~mgb [Edited by mgb on 04-30-2001 at 08:26 PM] |
|
|
|
|
|
#5 |
|
Risu Oyabun!
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
|
The spelling on itm is correct. I'm weird like that! I tried your recommendation and still no dice.
I suppose the best way of explaining my goal here is to site example. Check out http://www.were-here.com/forum/tutor...enu/index.html There is a tutorial I found that is basically what I'm trying to do... except that it was written in Flash4 and I'm trying to just dupe movie clips and change the text based on an array. |
|
|
|
|
|
#6 |
|
New Member
Join Date: Jan 2001
Posts: 245
|
Try;
_root["listbox.itm_" + i ].txt= _root.who[a-1]; ~mgb |
|
|
|
|
|
#7 | |
|
Registered User
Join Date: May 2001
Location: Groningen, Netherlands
Posts: 65
|
Quote:
You can check in the 'List Variables' screen if your textfields are filled correctly (so a least you can check if your code is ok). Hope this helps, Tilly |
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|