Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cycling with next and previous buttons

Status
Not open for further replies.

typeofdoug

Programmer
Feb 2, 2007
4
US
I'm pretty new to action script and have pieced together the bellow code from tutorials and other whatnots. At the bottom you'll see my 'forward/backward' script that cycles through my array. My question is how do I put my index specific buttons in the down state while 'forward/backward' buttons do their magic?

Movieclip.prototype.scrollme = function(xPos) {
//this gets the current X position of the clip calling the function
cX = this._x;
//this works out the distance between its current X position and where it has to go
difX = cX-xPos;
//this sets the new X position of the clip
//the clip moves 1/5th of the total distance every frame
this._x = cX-(difX/5);
};
stop();
//variable starting value
arrayIndex = 1;
//timeline stopping postions
timelineXpos = new Array(0, 0, -760, -1520, 305);
//scrolling animation
timeline.onEnterFrame = function() {
this.scrollme(timelineXpos[arrayIndex]);
};
//buttons that scroll the timeline to specific x positions
//but1
controller_mc.but1.onRollOver = function() {
this.frameHold = this._currentframe;
this.gotoAndStop("over");
};
controller_mc.but1.onRollOut = function() {
this.gotoAndStop(this.frameHold);
};
controller_mc.but1.onRelease = function() {
arrayIndex = 1;
for (var mc in this._parent) {
var thisHold = this;
if ((this._parent[mc] == thisHold) && (this._parent[mc]._name.indexOf("but") != -1)) {
this._parent[mc].gotoAndStop("on");
} else {
this._parent[mc].gotoAndStop("off");
}
}
this.frameHold = this._currentframe;
};
//but2
controller_mc.but2.onRollOver = function() {
this.frameHold = this._currentframe;
this.gotoAndStop("over");
};
controller_mc.but2.onRollOut = function() {
this.gotoAndStop(this.frameHold);
};
controller_mc.but2.onRelease = function() {
arrayIndex = 2;
for (var mc in this._parent) {
var thisHold = this;
if ((this._parent[mc] == thisHold) && (this._parent[mc]._name.indexOf("but") != -1)) {
this._parent[mc].gotoAndStop("on");
} else {
this._parent[mc].gotoAndStop("off");
}
}
this.frameHold = this._currentframe;
};
//but3
//
controller_mc.but3.onRollOver = function() {
this.frameHold = this._currentframe;
this.gotoAndStop("over");
};
controller_mc.but3.onRollOut = function() {
this.gotoAndStop(this.frameHold);
};
controller_mc.but3.onRelease = function() {
arrayIndex = 3;
for (var mc in this._parent) {
var thisHold = this;
if ((this._parent[mc] == thisHold) && (this._parent[mc]._name.indexOf("but") != -1)) {
this._parent[mc].gotoAndStop("on");
} else {
this._parent[mc].gotoAndStop("off");
}
}
this.frameHold = this._currentframe;
};
//
//timeline forward and backward buttons
controller_mc.goForward.onRelease = function() {
if (arrayIndex<3) {
arrayIndex++;
}
};
controller_mc.goBack.onRelease = function() {
if (arrayIndex>1) {
arrayIndex--;
}
};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top