Am working on adapting a script for a simon-type animation, which now has 6 flashing lights/buttons on stage. The "light" sequence is stored in an array, playOrder and then playOrder.concat stores the repeatOrder.
No matter how I try to modify the arrays (shift, pop, slice, etc.), when the first flashing light is correctly clicked, the next sequence, which includes that first light, flashes it twice, before going on to flash the next light, and the next light...once. This (flashing the first light twice) only happens for the first try, after which the sequence correctly flashes each and every light, once.
Have gone over the AS3, over and over, tried setting counters and if/else, plus the array modifications (shift, pop, slice, etc.), but can't get the light flash sequence to "behave" correctly. (Can't search the array for duplicates and remove, since in the random light script, duplicates can be part of random selections.)
I'll post the latest script here in a text file, in the hope that someone can spot what I'm missing, suggest a fix: http://elearningprojects.com/AS3script.txt
Any help appreciated.
Thanks for your reply. I tried using slice instead of concat but the problem remains: second sequence, after clicking on the correct single light for first sequence, that light (now first in a 2-light new, second sequence) flashes twice instead of once. Thereafter, in third, fourth...etc. sequences that first light only flashes (correctly) once. Can't get that double flash out.
there is nothing wrong with the array saratogacoach, I've got your code and will sort it out with you
and as for duplicating arrays
concat is apparently faster
you're correct. concat works.
but it's insignificantly faster than slice() similar to looping through a for-loop is faster backwards than forwards and using an int in a for-loop is faster than an uint.
it would be pretty amazing if anyone got far-enough into a simon-type game to see even a 1 ms difference between slice() and concat().