jefargrafx
Instructor
so I got this function that check the currentframe and depending on it's number goes to the nextframe or to the next frame in a loaded movie clip.
my question, any tutorials on condenseing code?
here are 27 same but differnet if statements, there's got to be a way to shorten this?
function pageforward() {
resettitle();
if (frameLabel == "intro"
{
gotoAndStop("page_01"
;
}
if (frameLabel == "page_01" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_02"
;
} else if (frameLabel == "page_01" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_02" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_03"
;
} else if (frameLabel == "page_02" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_03" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_04"
;
} else if (frameLabel == "page_03" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_04" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_05"
;
} else if (frameLabel == "page_04" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_05" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_06"
;
} else if (frameLabel == "page_05" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_06" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_07"
;
} else if (frameLabel == "page_06" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_07" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_08"
;
} else if (frameLabel == "page_07" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_08" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_09"
;
} else if (frameLabel == "page_08" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_09" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_10"
;
} else if (frameLabel == "page_09" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_10" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_11"
;
} else if (frameLabel == "page_10" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_11" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_12"
;
} else if (frameLabel == "page_11" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_12" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_13"
;
} else if (frameLabel == "page_12" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_13" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_14"
;
} else if (frameLabel == "page_13" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_14" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_15"
;
} else if (frameLabel == "page_14" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_15" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_16"
;
} else if (frameLabel == "page_15" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_16" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_17"
;
} else if (frameLabel == "page_16" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_17" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_18"
;
} else if (frameLabel == "page_17" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_18" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_19"
;
} else if (frameLabel == "page_18" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_19" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_20"
;
} else if (frameLabel == "page_19" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_20" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_21"
;
} else if (frameLabel == "page_20" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_21" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_22"
;
} else if (frameLabel == "page_21" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_22" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_23"
;
} else if (frameLabel == "page_22" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_23" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_24"
;
} else if (frameLabel == "page_23" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_24" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_25"
;
} else if (frameLabel == "page_24" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_25" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_26"
;
} else if (frameLabel == "page_25" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_26" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_27"
;
} else if (frameLabel == "page_26" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_27" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("intro"
;
} else if (frameLabel == "page_27" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
}
jef
my question, any tutorials on condenseing code?
here are 27 same but differnet if statements, there's got to be a way to shorten this?
function pageforward() {
resettitle();
if (frameLabel == "intro"
gotoAndStop("page_01"
}
if (frameLabel == "page_01" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_02"
} else if (frameLabel == "page_01" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_02" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_03"
} else if (frameLabel == "page_02" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_03" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_04"
} else if (frameLabel == "page_03" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_04" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_05"
} else if (frameLabel == "page_04" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_05" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_06"
} else if (frameLabel == "page_05" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_06" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_07"
} else if (frameLabel == "page_06" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_07" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_08"
} else if (frameLabel == "page_07" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_08" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_09"
} else if (frameLabel == "page_08" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_09" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_10"
} else if (frameLabel == "page_09" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_10" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_11"
} else if (frameLabel == "page_10" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_11" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_12"
} else if (frameLabel == "page_11" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_12" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_13"
} else if (frameLabel == "page_12" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_13" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_14"
} else if (frameLabel == "page_13" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_14" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_15"
} else if (frameLabel == "page_14" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_15" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_16"
} else if (frameLabel == "page_15" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_16" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_17"
} else if (frameLabel == "page_16" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_17" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_18"
} else if (frameLabel == "page_17" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_18" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_19"
} else if (frameLabel == "page_18" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_19" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_20"
} else if (frameLabel == "page_19" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_20" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_21"
} else if (frameLabel == "page_20" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_21" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_22"
} else if (frameLabel == "page_21" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_22" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_23"
} else if (frameLabel == "page_22" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_23" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_24"
} else if (frameLabel == "page_23" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_24" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_25"
} else if (frameLabel == "page_24" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_25" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_26"
} else if (frameLabel == "page_25" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_26" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("page_27"
} else if (frameLabel == "page_26" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
if (frameLabel == "page_27" and _root.page_MC._currentframe == _root.page_MC._totalframes) {
gotoAndStop("intro"
} else if (frameLabel == "page_27" and _root.page_MC._currentframe != _root.page_MC._totalframes) {
_root.page_MC.nextFrame();
}
}
jef