Trying to streamline if/then function

I am creating a word search game and am using this conditional statement to determine if the letter has been selected, then add or subtract a value dependent on that. I wrote the following function that works, but seems a bit lengthy - any ideas on how to streamline this function?

thanks!

if(e.currentTarget.name=="a1" && MovieClip(e.currentTarget.bak).currentFrameLabel =="on")
		{
			wordCount=-1.1;
		}
	if(e.currentTarget.name=="a1" && MovieClip(e.currentTarget.bak).currentFrameLabel =="off")
		{
			wordCount=1.1;
		}

Perhaps this, though the trade between memory and code length is one which I might not make.

if(e.currentTarget.name == "a1") {
    var s:String = MovieClip(e.currentTarget.bak).currentFrameLabel
    if(s == "on") wordCount = -1.1
    else if(s == "off") wordCount = 1.1
}

Don’t know how to format code…

const o:* = e.currentTarget
o.name == 'a1' && wordCount = o.bak['currentFrameLabel'] == 'on' ? -1.1 : 1.1

Not exactly equivalent if there are frames other than ‘on’ and ‘off’.

1 Like

Thanks!