Skip to main content
pawelk15640242
Known Participant
July 25, 2018
Answered

Error in program. Palindrome ActionScript3.0

  • July 25, 2018
  • 5 replies
  • 471 views

Need help identifying the error. Here is the code

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

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

btnCheck.addEventListener(MouseEvent.CLICK, checkWord);

// This is the checkWord function

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

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

function checkWord(e:MouseEvent):void

{

//declare the variables

var word:String;

// text in word

word = (txtinWord.text);

// reverse the word

if

(word = word); {

lblPalindrome.text = "This word is a palindrome";

}

else

{

lblPalindrome.text = "This word is not a palindrome";

}

}

program

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer ankushr40215001

I have found an Action Script code for Palindrome.

Please try the below code and let us know if that works for you.

function isPalindrome(str:String):Boolean

{

for(var first:uint = 0, second:uint = str.length - 1; first < second; first++, second--)

if(str.charAt(first) != str.charAt(second)) return false;

return true;

}

Thanks!

Ankush

5 replies

Legend
July 25, 2018

Sorry, I don't see what this has to do with C++.

pawelk15640242
Known Participant
July 25, 2018

Its actionscript 3.0, I am using Adobe Animate. Thats all I know.