I've looked for other threads on this, but haven't found anything that
has really helped me yet.

I've made a sorting function that dispatches an event every time it
swaps values in an array. The eventlistener calls a function that
updates a display to show visually how the array has changed. The
problem is that when I call the sort function, there's only a slight
hesitation and then the display changes to the end result.

I'm guessing that the changes are happening too fast for the user to
see. In a Java environment, I would just Thread.sleep during the sort
function to slow it down, but I can't do that in AS3.

Does anyone have any ideas? I've looked all over, but it's possible
I'm just not properly using the solutions I've found. 

In case it helps, here's the basic layout of the class:

class Sort {
  function partition(a:Array, l:int, r:int):int {
    // look around
    // swap values
    dispatchEvent(SortEvent.UPDATE); // SortEvent is a custom event
    // would like to pause this function here
    return value;
  } 
  function sort(a:Array, l:int, r:int) {
    if (l >= r) return;
    var i:int = partition(a,l,r);
    sort(a, l, i-1);
    sort(a, i+1, r);
  }
}

Reply via email to