开发者

Time-Scaling Movies in Flash

开发者 https://www.devze.com 2022-12-17 04:14 出处:网络
Time scaling movies in After Effects is easy, but how would I do that in Flash? Equations or actionScript would be appreciated.

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)); 
}


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号