Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Crosscheck two input text boxs.

Posted on 2005-03-23
2
Medium Priority
?
215 Views
Last Modified: 2012-08-14
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
Comment
Question by:lukegriffiths110
2 Comments
 
LVL 18

Expert Comment

by:Billystyx
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

by:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
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 Month15 days, 12 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question