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?


if("a1" && MovieClip(e.currentTarget.bak).currentFrameLabel =="on")
	if("a1" && MovieClip(e.currentTarget.bak).currentFrameLabel =="off")

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

if( == "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 == 'a1' && wordCount = o.bak['currentFrameLabel'] == 'on' ? -1.1 : 1.1

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

1 Like