-
Here's the scoop,
I have an array in frame 1 of the main timeline like this:
stop();
totals = new Array ();
I have a text field named newarra and button that updates the array and moves the main timeline to the frame 3:
on (press)
{totals.push(newarra);
}
on (release)
{_root.gotoAndStop(3);
}
This works fine. The user can add as many elements to the array as they like by seperating them with a comma.
My problem is that I need to know how many elements are in the array once the maintimeline gets to frame 3.
so in frame 3 I put these actions:
arralength = totals.length;
trace (arralength);
trace (totals);
in the output window arralength always returns a value of 1 regardless of the number of elements in the array.
Can anyone PLEASE shed some light? I'm stuck on this.
Dev_Flasher
-
Well I know the reason it is doing that but I dont have a solution. The reason that happens is because everything that the user types in the text field is made to be one element in the array...just take a look at your variables. Even if you add commas Flash just thinks its one element.
Now a possible solution would be to somehow parse through whatever the user types and return the text or numbers between the commas to seperate elements in your array.
Thats the best I could do...good luck.
-
Thank you,
But Oh how to parse the data.....
I'll reply when I figure it out. Or Maybe someone will know.
-
I figured it out
This works as long as the user inputs the elements with a space between them
on (press) {
var arrastring = new string(newarra);
}
on (release) {
// splits the string into an array
var parse = arrastring.split(" ");
// returns the number of elements in the array
// to the variable named arraylength
var arraylength = parse.length;
}
Thanks again for the idea ahab!
Dev_flasher
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|