• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Component variable to allow access to a frame

Community Beginner ,
Nov 02, 2021 Nov 02, 2021

Copy link to clipboard

Copied

Hello

 

Trying to create an password to access a frame.

 

I have an Animate component with an instance name of "TextInput_cmpnt".

I also have a custom submit button with an instance name of "submit_btn".

The following code is in the Actions layer:

 

_this.submit_btn.on('click', function(){

_this.myVar = "Name";

function checkPassword(){
if(TextInput_cmpnt.myVar="Paul" ){
_this.gotoAndPlay(4);
}else{
_this.gotoAndPlay(3);
}

}
checkPassword();
});

 

Any ideas on what. am doing wrong here will be much appreciated.

 

 

 

 

 

 

 

Views

135

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
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 03, 2021 Nov 03, 2021

Hi.

 

There is at least one problem in this line:

 

if (TextInput_cmpnt.myVar = "Paul")

 

 

- The equality operators are == or === (triple equals are mostly used in JavaScript);

- Also, do you have a property called myVar in your TextInput component instance?

 

Or maybe what you want is something like this?

 

var _this = this;

_this.submit_btn.on('click', function()
{
	if (TextInput_cmpnt.value === "Paul")
	{
		_this.gotoAndPlay(4);
	}
	else
	{
		_this.gotoAndPlay(3);
	}
});

 

 

Please let us k

...

Votes

Translate

Translate
Community Expert ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

Hi.

 

There is at least one problem in this line:

 

if (TextInput_cmpnt.myVar = "Paul")

 

 

- The equality operators are == or === (triple equals are mostly used in JavaScript);

- Also, do you have a property called myVar in your TextInput component instance?

 

Or maybe what you want is something like this?

 

var _this = this;

_this.submit_btn.on('click', function()
{
	if (TextInput_cmpnt.value === "Paul")
	{
		_this.gotoAndPlay(4);
	}
	else
	{
		_this.gotoAndPlay(3);
	}
});

 

 

Please let us know.

 

Regards,

JC

 

Votes

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
community guidelines
Community Beginner ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

JoãoCésar, than you very much!

 

It worked!

 

Truly appreciate your support.

 

Votes

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
community guidelines
Community Expert ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

LATEST

Amazing! You're welcome!

Votes

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
community guidelines