Skip to main content
Known Participant
September 4, 2022
Answered

problem form

  • September 4, 2022
  • 2 replies
  • 462 views

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 has been closed for replies.
    Correct answer JoãoCésar17023019

    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

    2 replies

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    September 13, 2022

    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

    Known Participant
    September 13, 2022

    Great, thank you very much, it works.

    Thanks for your help.

    JoãoCésar17023019
    Community Expert
    Community Expert
    September 13, 2022

    You're welcome!

    Known Participant
    September 4, 2022

    in the code of frame1 I put

    root2.gotoAndStop(2); 

    but that's not the problem

    Known Participant
    September 7, 2022

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