Search code examples
actionscript-3flash

AS3, change variable when "score" goes over set value


I'm trying to make a little game with AS3, for fun. I've never tried AS3 before and barely been into AS2. I'm VERY new to coding and I've not really tried to learn anything. Just stepped right into it.

So, I'm trying to make a rank, where the first one is "Hobo", and as it hits, say 100 experience, the rank should change to "Recruit".

My idea was (And sorry if this is really bad, it's all very new to me), but it doesn't work.

var rank:String = "Hobo";
if (exp <= 100){
    rank = "Recruit";
}else if (exp <= 500){
    rank = "Member";
}else{
    trace("Not enough exp")
}

Again, I'm new to both AS3 and coding, so this might be very bad or COMPLETELY the wrong way to do this. I apologize.

Would be incredibly nice if someone could explain why this doesn't work, and the proper way to do this.

Thank you very much for your answer.


Solution

  • How about this?

    var rank:String = "Hobo";
    if (exp >= 500){
        rank = "Member";
    }else if (exp >= 100){
        rank = "Recruit";
    }else{
        trace("Not enough exp")
    }