|
-
Button ActionScript Question
Hello,
I have a animation that is contained in a MC thats 1000 frames long.
I want to create a button that you can click on and manually to fast forward or rewind...I guess a slider bar kinda thing....I workin with flash MX
any suggestions..
thanks,
-
The best way I find for you to do this is to create a simple function of fast foward that does gotoAndPlay(_currentframe + 5), and use setInterval and clearInterval for it on the mouse press and mouse release events
-
Untitled-1.fla
Here's a quick slider bar thing. Create a movie clip that will act as you moving bar, place it on the stage where you want it to be located when that animation is at the start and add this code to it:
Code:
onClipEvent(load) {
startX = this._x;
sliderAreaSize = 200;
contentMC = _root.animationMC;
this.onPress = function() {
contentMC.stop();
this.onMouseMove = function() {
var frame = Math.round(contentMC._totalframes * (this._parent._xmouse-startX)/sliderAreaSize);
if (frame < 1) {
frame = 1;
} else if (frame > contentMC._totalframes) {
frame = contentMC._totalframes;
}
contentMC.gotoAndStop(frame);
}
}
this.onRelease = this.onReleaseOutside = function() {
this.onMouseMove = null;
contentMC.play();
}
}
onClipEvent(enterFrame) {
var scale = contentMC._currentframe/contentMC._totalframes;
this._x = startX + scale*sliderAreaSize;
}
You need to change sliderAreaSize, this is the length of the slider, meaning it's the distance the bar movie clip will move.
You also need to change contentMC so it points to the movie clip containing the animation. The code above will only work if your animation is on the main timeline and the instance is called animationMC.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|