Skip to main content
Known Participant
May 22, 2007
Question

Help Needed for Beginner

  • May 22, 2007
  • 5 replies
  • 344 views
HI

I am trying to create a whole simulation and im having problems wiht some aspects.

One is with a measuremnet swf i have. Basically it plays a video and the user has to enter the correct value into an input text area . I want it to give them three attempts and then it loads an external swf with some help guides and tips.

MY question is, how do i get it to count three incorrect entries and then close itself down and load another swf.

My code so far (whic works bar the three attempts) is

stop();


_root.submit_micrometer_btn.onRelease=function() {
if (_root.micrometer_answer_txt.text=="9.18") {
_root.unloadMovie();
} else {_root.response.text="Incorrect Answer Please Try Again"
}
};


PLease help!

Thank you

Becki
This topic has been closed for replies.

5 replies

Known Participant
May 22, 2007
Brilliant this has worked thank you Gorka Ludlow :)

Only one more quesiont....how would i get the input text field to clear after each attempt? at the moment it stays there



stop();

var error_count:Number=0;
_root.submit_micrometer_btn.onRelease=function() {
if (_root.micrometer_answer_txt.text=="9.18") {
_root.unloadMovie();
} else {_root.response.text="Incorrect Answer Please Try Again"
error_count++;
if(error_count==3){
_root.loadMovie("introduction.swf");
}
}
};
Inspiring
May 24, 2007
With one simple instruction:

stop();
var error_count:Number=0;
_root.submit_micrometer_btn.onRelease=function() {
if (_root.micrometer_answer_txt.text=="9.18") {
_root.unloadMovie();
} else {
// this is it
_root.micrometer_answer_txt.text = '';
_root.response.text="Incorrect Answer Please Try Again"
error_count++;
if(error_count==3){
_root.loadMovie("introduction.swf");
}
}
};

Cheers
Gorka
Inspiring
May 22, 2007
Well, how would you do it if you had to sit there and watch and count? The same would be for Flash.

You know that eveybody starts with zero tries, so:

numAttempts=0;

Then everytime they try and answer they have attempted it one more time. So inside the onRelease function.

numAttempts++;

If it is right you don't care so inside the first part of the if you don't need anything. But if they didn't get it right then you need to check how many times. So put something inside the else statement:

if(numAttempts>=maxTries){
trace("You've tried too many times. Let me help you.")
} else {
trace("Incorrect answer, please try again.");
}

Oh, I didn't mention maxTries. Generally I find that things like this get changed at the last minute, so it is easier to define a maxTries variable up at the top. Otherwise you end up going blind looking through all those lines of code.
Inspiring
May 22, 2007
how about this:

stop();

var error_count:Number=0;
_root.submit_micrometer_btn.onRelease=function() {
if (_root.micrometer_answer_txt.text=="9.18") {
_root.unloadMovie();
} else {_root.response.text="Incorrect Answer Please Try Again"
error_count++;
if(error_count==3){
_root.loadMovie('external_swf.swf',0);
}
}
};

Cheers
Gorka
Known Participant
May 22, 2007
yes if possible i have no idea how to get the whole thing working and its driving me mad (along with the rest of it as well!)
kglad
Community Expert
Community Expert
May 22, 2007
when you load your external swf do you want to unload the measurement swf?