• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

1+1=11??? ActionScript3

Community Beginner ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

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?

Views

246

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jan 19, 2021 Jan 19, 2021

Hi.

 

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

 

Regards,

JC

Votes

Translate

Translate
Community Expert , Jan 19, 2021 Jan 19, 2021

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;

 

Votes

Translate

Translate
Community Expert ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

Hi.

 

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

 

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

change it to number, it show NaN

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

Did you initialized it like...

var point:int = 0;

 ...?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

nope, just

var point:Number;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

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;

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

ah lovely, it work.. thx mate..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

LATEST

You're welcome!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines