Solved

# Crosscheck two input text boxs.

Posted on 2005-03-23
Medium Priority
206 Views
I am designing a very simple lotto game.

I have got to the point were I have two input boxes on a frame, one called Rand and the other called Guess. Rand contains a six digit random number, and guess contains the six digit inputted number guessed by the user.

What i want to do now is add a calculate button on this page. This means when the user clicks on the calculate button the frame displayed will jump to a prize frame, displaying what they have won. The frame displayed will deppend on how many numbers the user has guessed correct.

Can anyone help me with the code...
0
Question by:lukegriffiths110
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 18

Expert Comment

ID: 13612274
make a button on the original page. Also make sure you have variable names in both the input and dynamic text box. (different variable names)

on the button put this code:

on(release){
score=0;
for(i=0;i<compnum.length;i++){
if(compnum.substr(i,1)==usernum.substr(i,1)){
score++;
}
}
gotoAndPlay("framewithprizes");
}

on frame with frame label 'framewithprizes':

switch(score){
case: 1
prize="a new car";
case: 2
prize="an old car";
default:
prize="nothing";
}

Billystyx
0

LVL 39

Accepted Solution

blue-genie earned 2000 total points
ID: 13612290
what you need to do is go through the text (as a string) one character at a time.

so
for example, your randomstring and userstring

so .
var ran_str:String = "000000";
var my_str:String = "120566";
counter = 0;
for (i=0; i<ran_str.length; i++) {
if (my_str.charAt(i) == ran_str.charAt(i)) {
counter++;
trace(counter);
}
}

this way, if counter is equal to 6, then all 6 numbers are correct.

blu.

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
###### Suggested Courses
Course of the Month13 days, left to enroll