我的动画总共100帧。我想设置一系列帧。是否有命令只能播放50至75帧?我希望开始和结束帧位于我稍后可以调用的对象中。必须有一个“最好”的方式来做到这一点!
总共100帧 < ==玩50到75 ==> These commands work, but I would end up adding labels and stop();
//start playing at given frame
Play at 9950.00
gotoAndPlay(4990,"Scene 1");
//advance and stop at given frame
my_mc.gotoAndStop(my_mc.currentFrame + 10);
//control frame rate on stage
Frame rate command
stage.frameRate = 90;
我的电影的开头和结尾应该是它自己的一个对象。我的电影需要控制给定帧数的时间和持续时间。如果您有任何想法,请评论。
AS 3.0,计时器类,显示,时间缩放
Patricks示例修改了“我玩了值,但没有效果或错误”
import flash.display.MovieClip;
import fl.transitions.Tween;
import fl.transitions.easing.*;
//...
function playFromTo(from:int, to:int, duration:Number):Tween {
return new Tween(this, "tweenFrame", None.easeNone, from, to, duration, true);
}
//instance of tweenFrame on stage
var _tweenFrame:Number;
function set tweenFrame(value:Number):void{
//what about value?
_tweenFrame = value;
gotoAndStop(int(value));
}
function get tweenFrame():Number{
return _tweenFrame;
}
答案 0 :(得分:0)
一般的想法,不是开箱即用的解决方案:]
var _isPlaying:Boolean=false;
_timelineMovement:Boolean=false;
_stopMovementOn:Number;
addEventListener(Event.ENTER_FRAME, playTimeline);
function playTimeline(e:Event):void{
if (currentFrame == _stopMovementOn) { _isPlaying = false; }
if (!_isPlaying) { return false; }
gotoAndStop (currentFrame + _timelineMovement);
}
function playPart(from,to:Number):void{
if (_isPlaying) { doSomething(); }
if (to > from) { _timelineMovement= 1; } else { _timelineMovement = -1; }
_stopMovementOn = to;
_isPlaying = true;
}
OnEnterFrame在enterframe上调用,或者,如果影片在帧速率的每个刻度上停止(这使得这可缩放)。 playPart设置虚构Play()
,并且在每个刻度线上我们控制是否存在我们应该做的运动。非常简单:)
答案 1 :(得分:0)
使用未记录的addFrameScript()方法将代码添加到框架中。示例函数可能是这样的:
private function gotoAndPlayRange(target:MovieClip, startFrame:uint, endFrame:uint):void
{
target.addFrameScript(endFrame - 1, function():void
{
target.stop();
target.addFrameScript(endFrame - 1, null, false, false);
});
target.gotoAndPlay(startFrame);
}
addFrameScript的第一个参数是帧编号,但它基于零。这就是 -1 的原因。
答案 2 :(得分:0)
如果你想控制时间,加速度等......你可以使用tween推进游戏头,添加一个可以改变游戏头的吸气剂和设定器。
对于这个例子,我使用flash tweening,但你可以使用你想要的任何库。
package {
import flash.display.MovieClip;
import fl.transitions.Tween;
import fl.transitions.easing.*;
public class MyMC extends MovieClip {
//...
public function playFromTo(from:int, to:int, duration:Number):Tween {
// add a tween with no acceleration and a duration in second
return new Tween(this, "tweenFrame", None.easeNone, from, to, duration, true);
}
private var _tweenFrame:Number;
public function set tweenFrame(value:Number):void{
_tweenFrame = value;
gotoAndStop(int(value));
}
public function get tweenFrame():Number{
return _tweenFrame;
}
}
}
如果您无法修改MovieClip,请使用合成:
package {
import flash.display.MovieClip;
import fl.transitions.Tween;
import fl.transitions.easing.*;
public class TweenableMC {
private var _target:MovieClip;
public function TweenableMC(target:MovieClip):void {
_target=target;
}
public function playFromTo(from:int, to:int, duration:Number):Tween {
// add a tween with no acceleration and a duration in second
return new Tween(_target, "tweenFrame", None.easeNone, from, to, duration, true);
}
private var _tweenFrame:Number;
public function set tweenFrame(value:Number):void{
_tweenFrame = value;
gotoAndStop(int(value));
}
public function get tweenFrame():Number{
return _tweenFrame;
}
}
}
//...
var tm:TweenableMC=new TweenableMC(myMc);
tm.playFromTo(50, 75, 1); // play from 50 to 75 in 1 second