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

call function from button and inside function

Community Beginner ,
Dec 15, 2021 Dec 15, 2021

Copy link to clipboard

Copied

 

I have a function updateScreen to update text fields. I want to call the function from inside another buttons function.

 

function updateScreen() {

            (updates numerous text fields)

};

 

btnOne.addEventListener("click",  updateOne.bind(this));

function updateOne() {

           (changes variables);

           updateScreen()

}

Views

119

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 , Dec 15, 2021 Dec 15, 2021

Hi.

 

If your code lives in different instances, one approach would be to make the updateScreen function a method of the main timeline. Like this:

 

// CODE IN THE MAIN TIMELINE
this.updateScreen = function()
{
	// (updates numerous text fields)
};


// CODE SOMEWHERE ELSE
btnOne.addEventListener("click", updateOne.bind(this));

function updateOne()
{
	// (changes variables);
	// exportRoot is a global variable automatically created in the
	// publishing process that stores a reference to the ma
...

Votes

Translate

Translate
Community Expert ,
Dec 15, 2021 Dec 15, 2021

Copy link to clipboard

Copied

LATEST

Hi.

 

If your code lives in different instances, one approach would be to make the updateScreen function a method of the main timeline. Like this:

 

// CODE IN THE MAIN TIMELINE
this.updateScreen = function()
{
	// (updates numerous text fields)
};


// CODE SOMEWHERE ELSE
btnOne.addEventListener("click", updateOne.bind(this));

function updateOne()
{
	// (changes variables);
	// exportRoot is a global variable automatically created in the
	// publishing process that stores a reference to the main timeline
	exportRoot.updateScreen();
}

 

 

I hope this helps.

 

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