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

Need help with this syntax error that I can't identify. Made a program to determine A Right Triangle using Action Script 3.0 Adobe Animate CC

Community Beginner ,
Jul 19, 2018 Jul 19, 2018

This is the coding I made.

// This line makes the button, btnDetermine wait for a mouse click

   // When the button is clicked, the determineIfRightTriangle function is called

   btnDetermine.addEventListener(MouseEvent.CLICK, determineIfRightTriangle);

   // These lines make the label, lblResponce wait for a mouse click

   // When these components are clicked, the clearLabels function is called

   lblResponce.addEventListener(MouseEvent.CLICK, clearLabels);

   // This is the determineIfRightTriangle function

   // e:MouseEvent is the click event experienced by the button

   // void indicates that the function does not return a value

function determineIfRightTriangle(e:MouseEvent):void

{

// declare the variables

var lengthofside1:int;

var lengthofside2:int;

var lengthofside3:int;

var responce:String;

// get the length of sides from the user for the right angle triangle

lengthofside1 = int(txtinLengthOfSide1.text);

lengthofside2 = int(txtinLengthOfSide2.text);

lengthofside3 = int(txtinLengthOfSide3.text);

// calculate whether the sum of both lengthofside1 and lengthofside2 each squared equals lengthofside3 squared (which must be the greatest value)

if (Math.pow(lengthofside1, 2) + Math.pow(lengthofside2, 2)= Math.pow(lengthofside3, 2)

{

lblResponce.text = "These sides will make a Right Triangle, because X^2 + Y^2 = Z^2.";

}

else

{

lblResponce.text = "These sides will NOT make a Right Triangle, because X^2 + Y^2 ≠ Z^2.";

}

}

// This is the clearLabels function

// e:MouseEvent is the click event experienced by the label

// void indicates that the function does not return a value

function clearLabels(e:MouseEvent):void

{

lblResponce.text = "";

}

This is the program that I made for the windows actions. Sorry it is blurry you can try to zoom in.

TOPICS
ActionScript
730
Translate
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 1 Correct answer

Community Expert , Jul 19, 2018 Jul 19, 2018

use double equal to test equality.

your if-statement is missing a closing paranthesis

click file>publish settings and tick 'permit debugging' and retest.

the error messages will include the line number of the error.

Translate
Community Expert ,
Jul 19, 2018 Jul 19, 2018

use double equal to test equality.

your if-statement is missing a closing paranthesis

click file>publish settings and tick 'permit debugging' and retest.

the error messages will include the line number of the error.

Translate
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 ,
Jul 19, 2018 Jul 19, 2018

thanks for the reply, I don't quite understand what you mean by closing it with parenthesis. Is it in this line?

if (Math.pow(lengthofside1, 2) + Math.pow(lengthofside2, 2)= Math.pow(lengthofside3, 2)

I closed it with brackets twice but it still gave me an error. Also I don't know whether I close the Math.pow with brackets, or if I even use Math.pow. I searched online that it is used for multiplication but I don't know how to use it in this one.If you know could you please explain, it would help. 

Translate
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 ,
Jul 19, 2018 Jul 19, 2018

if (Math.pow(lengthofside1, 2) + Math.pow(lengthofside2, 2)= Math.pow(lengthofside3, 2)

should be

if (Math.pow(lengthofside1, 2) + Math.pow(lengthofside2, 2)== Math.pow(lengthofside3, 2))

Translate
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 ,
Jul 19, 2018 Jul 19, 2018

I replaced it, and it worked. Thank you.

Translate
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 ,
Jul 19, 2018 Jul 19, 2018

you're welcome.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

Translate
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
LEGEND ,
Jul 19, 2018 Jul 19, 2018

Allow me.

Translate
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 ,
Jul 19, 2018 Jul 19, 2018
LATEST

thank you!

Translate
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