//
// Triple Play - utilities for use in PlayN-based games
// Copyright (c) 2011-2013, Three Rings Design, Inc. - All rights reserved.
// http://github.com/threerings/tripleplay/blob/master/LICENSE

package tripleplay.flump;

import tripleplay.anim.Animation;

/** Plays through an entire movie once. */
public class PlayMovie extends Animation
{
    public PlayMovie (Movie movie) {
        _movie = movie;
    }

    @Override protected void init (float time) {
        super.init(time);
        _movie.setPosition(0);
    }

    @Override protected float apply (float time) {
        float elapsed = _movie.speed() * (time - _start);
        _movie.setPosition(elapsed);
        return _movie.symbol().duration - elapsed;
    }

    protected Movie _movie;
}

@@ -268,36 +268,29 @@
 ays 
-through an entire movie once
+a movie until it ends
 . */
@@ -489,28 +489,23 @@
    _
-movie.setPosition(0)
+lastTime = time
 ;%0A  
@@ -578,86 +578,147 @@
 oat 
-elapsed = _movie.speed() * (time - _start);%0A        _movie.setPosition(elaps
+dt = time - _lastTime;%0A        _lastTime = time;%0A%0A        float remaining = _movie.symbol().duration - _movie.position() - dt*_movie.spe
 ed
+(
 );%0A 
@@ -728,49 +728,169 @@
     
-return _movie.symbol().duration - elapsed
+if (remaining %3C 0) %7B%0A            dt = (_movie.symbol().duration-_movie.position()) / _movie.speed();%0A        %7D%0A        _movie.paint(dt);%0A        return remaining
 ;%0A  
@@ -922,10 +922,41 @@
 _movie;%0A
+    protected float _lastTime;%0A
 %7D%0A

Use paint() instead of setPosition() here.