• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 141
  • Last Modified:

making a button go through a set of arrays

a button on the screen and an input text box also on the screen .The user has to put a b or c in the input box that corrisponds to an 0 or 1
as the button is pushed it checks if caracter entered is a b or c -- the string (values) is converted to an array
if the value entered is not a b or c it will go to frame 31 that worn to use proper caracters
if a b or c entered is = to one it will goand stop to frame 11 telling correct
else it will go to frame 21 where it will say incorrect because the letter chosen is value 0!

this code is on the first frame of time liner

this code is on a button!
on(release) {
      if(((input.CharCodeAt(0)>64 && input.CharCodeAt(0)<68) || (input.CharCodeAt(0)>96
      && input.CharCodeAt(0)<100))) {
            for(var i=0;valuesArray.length;1++); {
                        if (input==valuesArray[i]);{
                        else {gotoAndStop(21);

else {
  • 2
1 Solution
Sorry, I'm not seeing what the question is here.  This looks like a description of the code.  What is the issue you would like assistance with?
>> if (input==valuesArray[i])

It doesnt make sense. You are comparing string "a","b" or "c" with "a=0", "b=0" and "c=0"
I agree with Savong, what exactly is the problem?

also, input - is that your var value or instance name?
I'm thinking u're using instance name as you're using CharAt etc, in which case you'll need input.text to get what the user has typed in.

try this code for the button:

on (release) {
      var frame_num:Number;
      if (((input.CharCodeAt(0)>64 && input.CharCodeAt(0)<68) || (input.CharCodeAt(0)>96 && input.CharCodeAt(0)<100))) {
            valuesArray = values.split(",");
            for (var i = 0; i<valuesArray.length; i++) {
                  if (input == valuesArray[i]) {
                        frame_num = 11;
                        // break for loop if correct
                  } else {
                        frame_num = 21;
      } else {
            frame_num = 31;

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now