Reputation: 5409
I have an array of sprites called segments
and I would like to skip the first element of segments
in my for each loop. I'm doing this at the moment:
var first = true;
for each (var segment in this.segments)
{
if(!first)
{
// do stuff
}
first == false;
}
Is there a better way to do this? Thanks!
Upvotes: 12
Views: 25053
Reputation: 4168
This can also be done via "slice". For example
for (var segment in this.segments.slice(1))
{
}
Array#slice
will copy the array without the first element.
Upvotes: 7
Reputation: 427
if its an array why not just:
for(var i:int = 1; i < this.segments.length; i++)
{
}
Upvotes: 12