PDA

View Full Version : Question on targets and duplicating movie clips


20 Ton Squirrel
04-30-2001, 10:11 PM
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]

mgb
04-30-2001, 11:13 PM
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

20 Ton Squirrel
04-30-2001, 11:22 PM
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

mgb
05-01-2001, 12:57 AM
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]

20 Ton Squirrel
05-02-2001, 04:56 PM
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/tutorials/Vertical_Scrolling_Menu/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.

mgb
05-03-2001, 06:18 PM
Try;

_root["listbox.itm_" + i ].txt= _root.who[a-1];

~mgb

Tilly
05-31-2001, 01:51 PM
Originally posted by 20 Ton Squirrel
The spelling on itm is correct. I'm weird like that! I tried your recommendation and still no dice.



Are you using a mask to partly cover your textfields? That will explain why your textfields aren't visible, because masking dynamic text will not work :-(
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