Skip to main content
Known Participant
Sep 4, 2022 9:00 AM UTC
Answered

problem form

Hi,

 

I have a very slight problem with a form.

I have in my frame0 a form to switch to frame1 :

 

 

this.stop();

var root = this;
var responseTF = this.responseTF;
var motdepassatrouver = "1234";
var input, button;

function onDrawEnd() {
	input = document.getElementById("mdp");
	button = document.getElementById("valider");
	button.addEventListener("click", validate);
}

function validate() {
	var value = input.value;

	if (value === "")
		responseTF.text = "MOT DE PASSE INCORRECT";
	else if (value === motdepassatrouver) {
		responseTF.text = "MOT DE PASSE     CORRECT";
		root.gotoAndStop(1); 
	} else {
		responseTF.text = "MOT DE PASSE INCORRECT";
	}

	input.value = "";
}
stage.on("drawend", onDrawEnd, root, true);

 

Everything is working.
And in frame1 I also use this same form to switch to frame2. I changed the names of variable and function but it blocks :

 

var root2 = this;
var responseTF2 = this.responseTF2;
var motdepassatrouver2 = "1234";
var input2, button2;

function onDrawEnd2() {
	input2 = document.getElementById("mdp2");
	button2 = document.getElementById("valider2");
	button2.addEventListener("click", validate2);
}
function validate2() {
	var value2 = input2.value2;

	if (value2 === "")
		responseTF2.text = "MOT DE PASSE INCORRECT";
	else if (value2 === motdepassatrouver2) {
		responseTF2.text = "MOT DE PASSE     CORRECT";
		root2.gotoAndStop(1); 

	} else {
		responseTF2.text = "MOT DE PASSE INCORRECT";
	}

	input2.value2 = "";
}

stage.on("drawend", onDrawEnd2, root2, true);

 

I did various tests but I can't see what is blocking.

I attached the file.

 

Thank you in advance for your help and answers.

Have a good day.

 

    This topic is closed to new replies. Start a new post to keep the conversation going.
    JoãoCésar17023019
    JoãoCésar17023019Correct answer
    Community Expert
    Sep 13, 2022 4:58 PM UTC

    Hi.

     

    Thank you for the file.

     

    Change the .value2 property on these two lines to .value because this is a property that belongs to the text element.

    var value2 = input2.value2; // change to .value
    input2.value2 = ""; // change to .value

     

    Also, in my case, I had do place the root2.responseTF2 text field inside of a Movie Clip instance to get a valid reference. In this way, I changed this line:

    var responseTF2 = this.responseTF2; // changed to this.movieClipContainerName.responseTF2

     

    I hope this helps and please let me know if it doesn't work.

     

    Regards,

    JC

    5 replies

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    Sep 13, 2022 4:58 PM UTC

    Hi.

     

    Thank you for the file.

     

    Change the .value2 property on these two lines to .value because this is a property that belongs to the text element.

    var value2 = input2.value2; // change to .value
    input2.value2 = ""; // change to .value

     

    Also, in my case, I had do place the root2.responseTF2 text field inside of a Movie Clip instance to get a valid reference. In this way, I changed this line:

    var responseTF2 = this.responseTF2; // changed to this.movieClipContainerName.responseTF2

     

    I hope this helps and please let me know if it doesn't work.

     

    Regards,

    JC

    Translate
    Known Participant
    Sep 13, 2022 6:40 PM UTC

    Great, thank you very much, it works.

    Thanks for your help.

    Translate
    JoãoCésar17023019
    Community Expert
    Community Expert
    Sep 13, 2022 7:00 PM UTC

    You're welcome!

    Translate
    Known Participant
    Sep 4, 2022 1:02 PM UTC

    in the code of frame1 I put

    root2.gotoAndStop(2); 

    but that's not the problem

    Translate
    Known Participant
    Sep 7, 2022 3:02 PM UTC

    I don't really understand my mistake,
    if anyone sees anything i thank you in advance

    Translate