Groups | Blog | Home
all groups > flash actionscript > june 2005 >

flash actionscript : How do I get a slider to go to the next or previous frame?


B.Sewall
6/16/2005 10:38:07 PM
Hello,

I'm building a Flash object VR controlled by a slider. There are 18 photos of
the object and the slider go to either the next or previous frame, based on
which way you slide it, making the object appear to spin one way or the other.

How do I code the slider to go to the next or previous frame?

See attched code that I have so far

Parent MC:

onClipEvent (load) {
initx = _x;
maxx = 230;
}
onClipEvent (mouseMove) {
posx = Math.round(_x-initx)+"%";
}


Child MC:

on (press) {
startDrag(this, false, initx, _y, initx+maxx, _y);
this._parent._parent.spin_mc.nextFrame();
}
on (release) {
stopDrag();
}
kglad
6/17/2005 12:52:05 AM
if you're using a horizontal slider you can create a movieclip that consists of
the slider's track aligned with its left edge at stage center and a slider
movieclip also aligned with its left edge at stage center.

position this on-stage and give it an instance name of trackMC and you can use:

trackMC.sliderMC.onPress = function() {
startX = 0;
endX = this._parent._width-this._width;
this.startDrag(0, startX, this._y, endX, this._y);
mcControlI = setInterval(mcControlF, 100, mc1); /*<-- mc1 is the movieclip
that you want this slider to control */
};
trackMC.sliderMC.onRelease = trackMC.sliderMC.onReleaseOutside=function () {
this.stopDrag();
clearInterval(mcControlI);
};
function mcControlF(mc) {
mc.gotoAndStop(Math.round(trackMC.sliderMC._x*(mc._totalframes-1)/endX+1));
}
AddThis Social Bookmark Button