views:

61

answers:

2

Time scaling movies in After Effects is easy, but how would I do that in Flash? Equations or actionScript would be appreciated.

Example

My movie's 60 seconds. I want to play the entire movie in 30 seconds. I want to play the entire movie in 120 seconds. How do I rescale my movie using actionScript 3.0. My movies are probably going to all be the same length and frame rate, if that makes a difference.

Example

Preloaders have elements effected by percentage and scale. I want to do this to movie clips, but have a defined total.

ex.

progressbar_mc.scaleX = loaded/total;

//Grapefruits example revised
//No errors at runtime, nothing happens?
//instance of "dude"
var _time_scale:Number = .25; 
var _frames_elapsed:int = 0; 
var dude:MovieClip; 

function handleEnterFrame(e:Event):void { 
_frames_elapsed++; 
dude.gotoAndStop(Math.round(dude.totalFrames 1 _frames_elapsed 2 _time_scale)); 
}
+1  A: 

It's fairly straightforward, this bit of code will play a MovieClip at quarter speed:

package {
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;

    public class Main extends Sprite {

        private var _time_scale:Number = .25;
        private var _frames_elapsed:int = 0;
        private var _clip:MovieClip;

        public function Main():void {
            _clip = new SomeClip;
            addEventListener(Event.ENTER_FRAME, handleEnterFrame);
        }

        private function handleEnterFrame(e:Event):void {
            _frames_elapsed++;
            // we multiply the "real" time with our timescale to get the scaled time
            // we also need to make sure we give an integer as a parameter, so we use Math.round() to round the value off
            _clip.gotoAndStop(Math.round(_clip.totalFrames * _frames_elapsed * _time_scale));
        }

    }

}

This method has one major caveat, there will be no interpolating between frames. This means that 10 frames of animation stretched out over 10s will be effectively 1fps. It will also skip frames if sped up, but that's less of an issue I guess.

grapefrukt
God help me, I love a good FLVPlayback hack. +1
iandisme
That's what I was looking for. Thanks.
VideoDnd
+1  A: 

I don't think what you're describing is possible in AS3 without a hack like grapefrukt gave you. There is a third-party app that will do this for Flash videos that you watch, but you'll pay for the privilege.

iandisme
When I attach the script and run it, I get an error???1151: A conflict exists with definition _clip in namespace internal.
VideoDnd
no error now, but doesn't do anything? See update in question.
VideoDnd