Skip to main content
Participant
January 19, 2021
Answered

1+1=11??? ActionScript3

i use this fucion

 

function ke_c2(event:MouseEvent):void
{
cek_a.visible=false;
cek_b.visible=false;
cek_c.visible=true;
cek_d.visible=false;
soal_selanjutnya.visible=true;
hasil = "Right Answer";
point +=1;
pointext.text = point.toString();
hasiltext.text = hasil;
a2.visible=false;
b2.visible=false;
c2.visible=false;
d2.visible=false;
}
 
so instead of 1+1=2 it show me 1+1=11. What i did wrong?
    This topic is closed to new replies. Start a new post to keep the conversation going.
    JoãoCésar17023019
    JoãoCésar17023019Correct answer
    Community Expert
    January 19, 2021

    nope, just

    var point:Number;

    That's the problem.

     

    You need to initialize a numeric variable before trying to do any mathematical operations on it.

     

    Just give it a value like 0.

    var point:Number = 0;

     

    7 replies

    JoãoCésar17023019
    Community Expert
    Community Expert
    January 19, 2021

    Hi.

     

    Probably because your point variable is a string. Can you check this?

     

    Regards,

    JC

    Translate
    Raa5CC4Author
    Participant
    January 19, 2021

    change it to number, it show NaN

    Translate
    JoãoCésar17023019
    Community Expert
    Community Expert
    January 19, 2021

    Did you initialized it like...

    var point:int = 0;

     ...?

    Translate