Donavan_usa
asked on
500 Big Ones! How do I Remove a comma from a Flash Array
Hi guys - I hope this is an easy one
How do I remove the 'comma' from appearing in the following array generated in Flash:
numberofItems = A;
// creating the arrays
message = new Array();
// loop to get all the variable names associated with their corresponding array positions
for (n=0; n<=numberofItems; n++) {
// adding the association of "label1, label2...label#" with items array
set("label" + n, scrollContent["myMovie"+n] .variableA );
message.push(eval("label"+ n));
}
The new variable called 'message' returns the following values:
message=,label1, label2, label3, etc
I would like to remove the ',' comma from the above generated array so it only displays the values label1 then label2
Cheers
How do I remove the 'comma' from appearing in the following array generated in Flash:
numberofItems = A;
// creating the arrays
message = new Array();
// loop to get all the variable names associated with their corresponding array positions
for (n=0; n<=numberofItems; n++) {
// adding the association of "label1, label2...label#" with items array
set("label" + n, scrollContent["myMovie"+n]
message.push(eval("label"+
}
The new variable called 'message' returns the following values:
message=,label1, label2, label3, etc
I would like to remove the ',' comma from the above generated array so it only displays the values label1 then label2
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have done some digging - would something like splice work (please see below) to remove unwanted data in the array?
numberofItems = A;
// creating the arrays
message = new Array();
// loop to get all the variable names associated with their corresponding array positions
for (n=0; n<=numberofItems; n++) {
// adding the association of "label1, label2...label#" with items array
message.splice(1, 5, ","); // start at the first index, count to '5' and remove the "," however it does not work
set("label" + n, scrollContent["myMovie"+n] .variableA );
message.push(eval("label"+ n));
}
numberofItems = A;
// creating the arrays
message = new Array();
// loop to get all the variable names associated with their corresponding array positions
for (n=0; n<=numberofItems; n++) {
// adding the association of "label1, label2...label#" with items array
message.splice(1, 5, ","); // start at the first index, count to '5' and remove the "," however it does not work
set("label" + n, scrollContent["myMovie"+n]
message.push(eval("label"+
}
just put my code after populating array, after for loop
The simplest solution is to change you loop from...
for (n=0; n<=numberofItems; n++) {
to...
for (n=1; n<=numberofItems; n++) {
for (n=0; n<=numberofItems; n++) {
to...
for (n=1; n<=numberofItems; n++) {
Well, just to put it out there..
You are tracing a Array. Whatever you do, as long as you are tracing the array, the comma's ( , ) will still be there. You'll have to convert it to a String, and then remove the commas.
You are tracing a Array. Whatever you do, as long as you are tracing the array, the comma's ( , ) will still be there. You'll have to convert it to a String, and then remove the commas.
ASKER
Where would you place the above script? I have tried a number of places and none of them seem to work. The only place that generated a response is enclosed below - it does remove the ',' but it also deletes the entire previous lable when it does
numberofItems = A;
// creating the arrays
message = new Array();
// loop to get all the variable names associated with their corresponding array positions
for (n=0; n<=numberofItems; n++) {
// adding the association of "label1, label2...label#" with items array
message.shift();
set("label" + n, scrollContent["myMovie"+n]
message.push(eval("label"+
}