Hi,
I have a Flash movie with two simple buttons.
Clicking button A adds some test data to an array called "list" and dumps it to the Output window. This
works fine. I can see the data.
Clicking button B simply dumps the array to Output so I can inspect it. However, whenever I click B, the array is always empty.
The code looks like this:
On frame 1 of the main timeline, I place the following script (in its own layer):
list = new Array();
function writeToList()
{
list.push("joe"
list.push("anne"
list.push("fred"
}
function dumpList()
{
trace("the list contains " + list.length + " items"
var i;
for (i = 0; i < list.length; i++)
{
trace("item [" + i + "] = " + list);
}
}
The script for button A is:
on (release)
{
writeToList();
dumpList();
}
The script for button B is:
on (release)
{
dumpList();
}
If I push values onto the array immediately after creating it (outwith the functions), they persist.
But any items I add interactively just vanish.
I've also tried initialising the array with a specified size, but still no luck.
Can anyone tell me how to get this to work?
Thanks.
I have a Flash movie with two simple buttons.
Clicking button A adds some test data to an array called "list" and dumps it to the Output window. This
works fine. I can see the data.
Clicking button B simply dumps the array to Output so I can inspect it. However, whenever I click B, the array is always empty.
The code looks like this:
On frame 1 of the main timeline, I place the following script (in its own layer):
list = new Array();
function writeToList()
{
list.push("joe"
list.push("anne"
list.push("fred"
}
function dumpList()
{
trace("the list contains " + list.length + " items"
var i;
for (i = 0; i < list.length; i++)
{
trace("item [" + i + "] = " + list);
}
}
The script for button A is:
on (release)
{
writeToList();
dumpList();
}
The script for button B is:
on (release)
{
dumpList();
}
If I push values onto the array immediately after creating it (outwith the functions), they persist.
But any items I add interactively just vanish.
I've also tried initialising the array with a specified size, but still no luck.
Can anyone tell me how to get this to work?
Thanks.