-
Check if input text is the same as text from file.
Hello, so I have an input text field on the stage, and also button "check". When something is written in the input text, after clicking "check" button , a message "Correct" or "Wrong" should be displayed in a dynamic text field, accordingly, if it the inputed text is the same as the text from file.
The text file is :
content0=Cat
&content1=Dog
&content2=Mouse
&content3=Bear
each frame should consist of one word from text file(layer 1 text input should be "Cat". If it is written in the text input correctly, the message "Correct" is displayed.
I have buttons "Previous word" and "Next word" on stage too. Ofcourse, if, for example, the line &content3=Bear is deleted from text file, the frame for that text input is also "deleted" in the swf movie.
Could this be possible in flash?
The files so far :
InputCheck.fla
inputcheck_words.txt
-
.
Hi,
You didn't have any code in the file, but anyways it's very similar to the other file in the way you get the text file and so on.
PHP Code:
stop();
var Words:Array = [];
var Words2:Array = [];
var Layer:Number = 0;
var total:Number;
mainText.text = "Layer " + Layer;
myData1 = new LoadVars();
myData1.onLoad = function(Success:Boolean)
{
if (Success)
{
var i:Number = 0;
while (this["content" + i] != undefined)
{
Words.push(this["content" + i]);
i++;
}
myText_txt.text = Words[Layer];
total = Words.length - 1;
}
};
myData1.load("inputcheck_words.txt");
function hideButtons()
{
if (Layer > 0 && Layer < total)
{
but_prev._visible = true;
but_next._visible = true;
}
else if (Layer > 0 && Layer >= total)
{
but_prev._visible = true;
but_next._visible = false;
}
else
{
but_prev._visible = false;
but_next._visible = true;
}
}
hideButtons();
but_next.onPress = function()
{
Layer++;
hideButtons();
nextFrame();
mainText.text = "Layer " + Layer;
myText_txt.text = Words[Layer];
message.text = "";
};
but_prev.onPress = function()
{
Layer--;
hideButtons();
prevFrame();
mainText.text = "Layer " + Layer;
myText_txt.text = Words[Layer];
message.text = "";
};
but_check.onPress = function()
{
if(input.text.length < 1)
{
message.text = "Enter a word";
}
else if (Words[Layer].indexOf(input.text) != -1)
{
message.text = "Correct";
}
else
{
message.text = "Wrong";
}
};
it is case sensitive too
-
.
Hi,
You can remove the code *var Words2:Array = [];*, I meant to delete it, thought I had
-
Designer, Programmer, Musician
I don't see the point of making a new thread for this, instead of just replying to the other one, same project, but hehe anyways.
That's practically almost all the script i made. Try the script fruitbeard modified, if no success, let us now.
PS: Odd , in the .fla there is no code o.O
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|