Highlighted

if/else statement not recognizing text input component

Explorer ,
Dec 25, 2019

Copy link to clipboard

Copied

Just a bump of my old topic. I'm using the built in text input field component with an if else statement. First see my code:

 

this.button1.addEventListener('click', bF.bind(this));
function bF(){
	if (this.toName.text == "") {
		this.status.text = "please enter a to name";
	} else {
		this.gotoAndStop(1);
		this.status.text = "Sending Ecard - Please Hold";
}}

 

(this is just a quick sample)
status is a dynamic textbox and correctly displays its message of sending ecard.

toName is the text input component... and it's being completely ignored. even left blank, it still pushes the sending message. just to test, i made toName a dynamic text and left it blank, the above code recognized it as blank and status gave me "please enter..."

now I'm not sure, but maybe I have to utilize this following code somehow... maybe someone out there knows?:

 

dom_overlay_container.children["toName"].???;

 

the ??? just means "can I put something here that lets my if else statement recognize it the same way it recognizes my dynamic text example?" 

 

Thanks for your time!

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

use the code snippets to see how to reference components.  in your case,you would see you should use:

 

if($('#toName').val()== ""){  // if toName is an input tf component

$('#status).val('please enter a to name');  // if status is an input tf component. 

this.status.text = "please enter a to name" ;  // if status is a dynamic tf 

} else {

etc

}

TOPICS
Code

Views

420

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

if/else statement not recognizing text input component

Explorer ,
Dec 25, 2019

Copy link to clipboard

Copied

Just a bump of my old topic. I'm using the built in text input field component with an if else statement. First see my code:

 

this.button1.addEventListener('click', bF.bind(this));
function bF(){
	if (this.toName.text == "") {
		this.status.text = "please enter a to name";
	} else {
		this.gotoAndStop(1);
		this.status.text = "Sending Ecard - Please Hold";
}}

 

(this is just a quick sample)
status is a dynamic textbox and correctly displays its message of sending ecard.

toName is the text input component... and it's being completely ignored. even left blank, it still pushes the sending message. just to test, i made toName a dynamic text and left it blank, the above code recognized it as blank and status gave me "please enter..."

now I'm not sure, but maybe I have to utilize this following code somehow... maybe someone out there knows?:

 

dom_overlay_container.children["toName"].???;

 

the ??? just means "can I put something here that lets my if else statement recognize it the same way it recognizes my dynamic text example?" 

 

Thanks for your time!

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

use the code snippets to see how to reference components.  in your case,you would see you should use:

 

if($('#toName').val()== ""){  // if toName is an input tf component

$('#status).val('please enter a to name');  // if status is an input tf component. 

this.status.text = "please enter a to name" ;  // if status is a dynamic tf 

} else {

etc

}

TOPICS
Code

Views

421

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 25, 2019 0
Adobe Community Professional ,
Dec 25, 2019

Copy link to clipboard

Copied

use the code snippets to see how to reference components.  in your case,you would see you should use:

 

if($('#toName').val()== ""){  // if toName is an input tf component

$('#status).val('please enter a to name');  // if status is an input tf component. 

this.status.text = "please enter a to name" ;  // if status is a dynamic tf 

} else {

etc

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 25, 2019 1
Explorer ,
Dec 25, 2019

Copy link to clipboard

Copied

Woah I was way off xD  Thanks a million and Merry Christmas. This indeed worked. I do have one last question, however it might need its own topic... but taking a shot in the dark, maybe I can tinker with it during the break..


The old AS code in the button was this.

loadVariablesNum ("SendEcard.php", 0, "POST");


There wouldn't happen to be a JS equivalent to this would there?
 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 25, 2019 0
kglad LATEST
Adobe Community Professional ,
Dec 26, 2019

Copy link to clipboard

Copied

no, that as2 code won't work. you'll need to use javascript when creating html5/canvas applications.

 

because you're using a component, animate adds jquery (a helper library) to your project and jquery is much easier to use than javascript.  in fact, you could use:

 

$.load("SendEcard.php", function(response, status, xhr) {

if (status == "error") {

console.log(xhr.status + " " + xhr.statusText);

} else if(status == "success"){

parseF(response);

}

});

 

function parseF(r){

// handle the return r from your php file

}

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 26, 2019 0