Here’s what I’m trying to do… I’m basically making a step-by-step tutorial. There is a nav section of just 2 buttons, one for the “previous step,” and the other for the “next step.”
Just to make it easier (or maybe not…) I’ve named all instances of my movieclips “mc1” “mc2” etc… And I’ve created ActionScript that notes what “page” you’re on, and using a for loop, makes the movieclip that corresponds to the current page (page #2 >> mc2) visible while at the same time making every other movieclip invisible. I’ve got all of that working properly.
What I need to fix is… Say you view the first step’s movieclip, and you go on to the next step, but then want to go back to the previous step to watch it again… What you’ll see is the last stopped frame of that movieclip rather than seeing the entire animation over again.
You’ll be able see what it’s doing in the code…
stop();
// Declare variables
pageNumber = 1;
maxPageNumber = 12;
progressBarSize = 430;
// Show only the movieclip which corresponds to the
// current "pageNumber"... since its the beginning, it's just "mc1"
showMovieclip();
// Event handlers
nav_next.onRelease = function () { nextMovieclip(); }
nav_prev.onRelease = function () { prevMovieclip(); }
///////////////////////
//// FUNCTIONS ////
///////////////////////
// Make each movieclip invisible except
// the one that corresponds with "pageNumber"
function showMovieclip()
{
// Hide or show the movieclips
for (i=1; i<=maxPageNumber; i++)
{
if (i != pageNumber) setProperty("mc"+i, _visible, false);
else setProperty("mc"+i, _visible, true);
}
// Enable or disable the nav buttons
if (pageNumber == 1) nav_prev.enabled = false;
else nav_prev.enabled = true;
if (pageNumber == maxPageNumber) nav_next.enabled = false;
else nav_next.enabled = true;
// Calculate progress bar
progressbar1.progressbar2._width = (pageNumber / maxPageNumber) * progressBarSize;
}
// Go to the next page... meaning change "pageNumber"
function nextMovieclip()
{
if (pageNumber < maxPageNumber) pageNumber++;
showMovieclip();
}
// Go to the previous page... meaning change "pageNumber"
function prevMovieclip()
{
if (pageNumber > 1) pageNumber--;
showMovieclip();
}
I know that I can use setProperty to reference something like “mc”+i, but can I do the same thing with play()? Obviously “mc”+i.play(); doesn’t work…
I’m sure there’s a way I can do it. Someone please just fill me in!
Thanks in advance,
Matt