Search code examples
actionscript-3flash

Trigger a frame update in Flash


I've encountered a case where I'm calling code that causes a flicker in a bitmap data. Without changing the frame rate to a much higher value (don't know if this is possible to change dynamically at runtime) is it possible to redraw the frame quickly?

In the old days you could cause Flash Player to manually update the frame by calling updateAfterEvent(). Does this still work? Is there another way to update the frame?

Here is what I have so far:

// force redraw
var updateEvent:MouseEvent = new MouseEvent(MouseEvent.MOUSE_MOVE);
updateEvent.updateAfterEvent();

If it's local variables will this get garbage collected?


Solution

  • If you're changing a something during enter frame listener, it should get updated automatically. Otherwise, use updateAfterEvent() in a non-enterframe listener.

    function onMouseMove(e:MouseEvent):void {
        //  ... code that changes something
        e.updateAfterEvent();
    }