Yes,
but wouldn't this iterate through the event srom start to end ?
What I want to do is if I have 600 events on a track then process
the 600th first, then the 599th, then the 598th and so on...
If I understand correctly your code will process events in order
0 -> 1-> 2 -> .... 599.
Regards:
Zsolt
Ok, but there is only the moveNext() method I know of for enumerations
but not movePrevious() or something.
Neverthless I solved the problem by making an array and use the array's
reverse() method :)))
Thanks:
Zsolt
Be careful though you don't actually change elements in the container (track) within the loop body, like removing events from the track while looping through all events of a track, or moving them to another track. This would break your loop. In such a case, you must first put all events you want to loop through into another container and then loop through this one (which is not so inefficient because it is all done "by reference". So, for example:
...
import System.Collections;
...
var queue = new Queue; // All selected video events
for (var e in track.Events)
{ if (e.Selected) queue.Enqueue(e); }
for (var e in queue) { .... }
Note that this would loop events in normal order (1...x). To reverse the order, use "Stack" instead of "Queue" and "Push" instead of "Enqueue".
Events are sorted by start time. When you access them by index or
using an enumerator, any changes to that effect the sort order will
also change the index and enumeration order.
So for example, to delete every other event in a track you'd do
something like this:
var events : Events = Vegas.Project.Tracks[0].Events;
var eventsToDelete : ArrayList = new ArrayList();
var enumEvents : IEnumerator = events.GetEnumerator();
var toggle : Boolean = false;
while (enumEvents.MoveNext()) {
if (toggle) {
eventsToDelete.Add(enumEvents.Current);
toggle = false;
} else {
toggle = true;
}
}
enumEvents = eventsToDelete.GetEnumerator();
while (enumEvents.MoveNext()) {
events.Remove(enumEvents.Current);
}