Like the title says, I'm using Brendan Dawes dsf classes. Rewind.as has the onComplete property - but not the Timeline.as - can this be added to the .as file?
I need to trigger an action when the playhead reaches frame 1 - the rewind.as is too slow for the 100 frame movie I'm working with, but the Timeline.as works perfectly - if I can set up a listener for the onComplete.
Thanks in advance for anyone's input!
Timeline.as:
Code:
/**
Move playhead of the targeted MovieClip to a specified frame over time
@author Brendan Dawes
@version 1.0
@example
<code>
var f:Timeline = new Timeline(instanceName,1);
f.movePlayheadTo(100,5);
</code>
*/
class com.dragslidefade.Timeline {
private var target:MovieClip;
private var depth:Number;
/**
@param target the MovieClip you want to control
@param depth the depth of the MovieClip
*/
function Timeline($target:MovieClip,$depth:Number) {
target = $target;
depth = $depth;
}
/**
@param f the frame number you want to move to
@param s the speed of the tween - higher numbers are slower
*/
public function movePlayheadTo (f:Number,s:Number){
target.createEmptyMovieClip("dsf_timeline",depth);
target.dsf_timeline.targetF = f;
target.dsf_timeline.startSpeed = s;
target.dsf_timeline.precision = 2;
target.dsf_timeline.onEnterFrame = function(){
//trace(this._parent._currentframe);
if(Math.abs(this._parent._currentframe - this.targetF) < this.precision){
this._parent.gotoAndStop(this.targetF);
this.removeMovieClip();
}
this.newFrame = Math.round(this._parent._currentframe -= (this._parent._currentframe - this.targetF)*.1);
this._parent.gotoAndStop(this.newFrame);
}
}
}
Rewind.as:
Code:
/**
Rewind Class
@version 1.0
@author Brendan Dawes
*/
class com.dragslidefade.Rewind {
private var target:MovieClip;
private var depth:Number;
/**
Rewinds the timeline to a specified frame
@param $target the instance name of the MovieClip you want to rewind
@param $depth the depth of the script clip - usually 1 is fine
@example
<code>
var c:Rewind = new Rewind(mc_name);
c.rewindTimeline(1);
</code>
*/
public var onRewindComplete:Function;
public function Rewind($target:MovieClip,$depth:Number) {
target = $target;
depth = $depth;
}
/**
@param frameNumber the frame to rewind to
*/
public function rewindTimeline(frameNumber:Number) {
var pointer:Object = this;
if (frameNumber < target._currentframe) {
target.createEmptyMovieClip("dsf_Rewind",depth);
target.dsf_Rewind.onEnterFrame = function() {
this._parent.prevFrame();
if (this._parent._currentframe <= frameNumber) {
this._parent.stop();
pointer.onRewindComplete();
delete this.onEnterFrame;
this.removeMovieClip();
}
}
}
}
}