Combined Code
frame 1 {
function randRange(min, max) {
var v1 = Math.floor(Math.random() * (max - min + 1)) + min;
return v1;
}
function nextPhase() {
if (NextPhase == 'eat') {
CurrentPhase = NextPhase;
}
if (CurrentPhase == 'eat') {
if (NextPhase == 'eat') {
_root.char.gotoAndPlay('eat1');
} else {
if (NextPhase == 'mix') {
MixTimer += randRange(3, 8);
if (MixTimer >= MixMaxTime) {
x = randRange(0, PhaseList.length - 1);
CurrentPhase = PhaseList[x];
if (CurrentPhase == 'eat') {
_root.char.gotoAndPlay('eat1');
} else {
_root.char.gotoAndPlay('eat2');
}
MixTimer = 0;
} else {
CurrentPhase = 'eat';
_root.char.gotoAndPlay('eat1');
}
} else {
CurrentPhase = NextPhase;
_root.char.gotoAndPlay('eat2');
}
}
} else {
if (NextPhase == 'mix') {
MixTimer += randRange(1, 3);
if (MixTimer >= MixMaxTime) {
x = randRange(0, PhaseList.length - 1);
CurrentPhase = PhaseList[x];
if (CurrentPhase == 'eat') {
_root.char.gotoAndPlay('eat1');
}
MixTimer = 0;
} else {}
} else {
CurrentPhase = NextPhase;
}
if (CurrentPhase != 'eat') {
_root.char.gotoAndPlay(CurrentPhase);
}
}
}
var CurrentPhase = 'idle';
var NextPhase = 'idle';
var PhaseList = new Array('kiss', 'lick1', 'lick2', 'rim', 'eat');
var MixMaxTime = 8;
var MixTimer = 0;
_root.btn1.onRelease = function () {
NextPhase = 'idle';
};
_root.btn2.onRelease = function () {
NextPhase = 'kiss';
};
_root.btn3.onRelease = function () {
NextPhase = 'lick1';
};
_root.btn4.onRelease = function () {
NextPhase = 'lick2';
};
_root.btn5.onRelease = function () {
NextPhase = 'rim';
};
_root.btn6.onRelease = function () {
NextPhase = 'eat';
};
_root.btn7.onRelease = function () {
NextPhase = 'mix';
if (CurrentPhase == 'idle' || CurrentPhase == 'eat') {
MixTimer = MixMaxTime;
}
};
}
movieClip 138 {
frame 31 {
_root.nextPhase();
}
frame 72 {
_root.nextPhase();
}
frame 88 {
_root.nextPhase();
}
frame 99 {
_root.nextPhase();
}
frame 125 {
_root.nextPhase();
}
frame 286 {
_root.nextPhase();
}
frame 352 {
_root.nextPhase();
}
}
// unknown tag 88 length 63