Hi.
There are a few different ways you can do this. For example:
// Logical OR (||) operator
function playjump()
{
if (this.currentFrame === 6 || this.currentFrame === 12 || this.currentFrame === 18 || this.currentFrame === 24)
this.gotoAndPlay(54);
else
this.gotoAndPlay(73);
}
this.bulbut2.addEventListener("click", playjump.bind(this));
// Switch statement
function playjump()
{
switch(this.currentFrame)
{
case 6:
case 12:
case 18:
case 24:
this.gotoAndPlay(54);
break;
default:
this.gotoAndPlay(73);
}
}
this.bulbut2.addEventListener("click", playjump.bind(this));
// Else if
function playjump()
{
if (this.currentFrame === 6)
this.gotoAndPlay(54);
else if (this.currentFrame === 12)
this.gotoAndPlay(54);
else if (this.currentFrame === 18)
this.gotoAndPlay(54);
else if (this.currentFrame === 24)
this.gotoAndPlay(54);
else
this.gotoAndPlay(73);
}
this.bulbut2.addEventListener("click", playjump.bind(this));
// Object literal
var targetFrames = { 6, 12, 18, 24 };
function playjump()
{
if (targetFrames[this.currentFrame] !== undefined)
this.gotoAndPlay(54);
else
this.gotoAndPlay(73);
}
this.bulbut2.addEventListener("click", playjump.bind(this));
// Object literal and ternary operator
var targetFrames = { 6, 12, 18, 24 };
function playjump()
{
this.gotoAndPlay(targetFrames[this.currentFrame] !== undefined ? 54 : 73);
}
this.bulbut2.addEventListener("click", playjump.bind(this));
// Array
var targetFrames = [ 6, 12, 18, 24 ];
function playjump()
{
if (targetFrames.indexOf(this.currentFrame) > -1)
this.gotoAndPlay(54);
else
this.gotoAndPlay(73);
}
this.bulbut2.addEventListener("click", playjump.bind(this));
// Array and ternary operator
var targetFrames = [ 6, 12, 18, 24 ];
function playjump()
{
this.gotoAndPlay(targetFrames.indexOf(this.currentFrame) > -1 ? 54 : 73);
}
this.bulbut2.addEventListener("click", playjump.bind(this));
I hope these help. Regards, JC
... View more