Highlighted

Calling member functions of symbols

New Here ,
Jul 04, 2020

Copy link to clipboard

Copied

I'm trying to make an easily reusable button object for navigating to different frames in my main timeline.   So after importing the object you would only need this one line of code, calling the updateButton member function to change the label text and target frame for the button:

this.myButton3.updateButton(2, "Continue")

 

The following code is included in frame 1 of a Movie Clip object, with instance name myButton3.   (To attach javascript, I wrapped this Movie Clip around a basic button with instance name baseButton)

//update button used for navigation
this.updateButton = function(targetFrameNum, newText, visibility = true){ 
	this.visible = visibility; 
	this.baseButton.label.text = newText;	
	this.addEventListener("click", function(){exportRoot.gotoAndPlay(targetFrameNum - 1)}.bind(exportRoot), {once: true});  //only clickable once.
}.bind(this);

 

Unfortunately I am having issues with calling updateButton from the main timeline.  I think the function is not declared until after the 1st frame of myButton3 executes, so I am getting errors about this.myButton3.update() being undefined. 

Is there a better way to declare the updateButton member function to make it easily callable from the main timeline?

TOPICS
Other

Views

29

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

Calling member functions of symbols

New Here ,
Jul 04, 2020

Copy link to clipboard

Copied

I'm trying to make an easily reusable button object for navigating to different frames in my main timeline.   So after importing the object you would only need this one line of code, calling the updateButton member function to change the label text and target frame for the button:

this.myButton3.updateButton(2, "Continue")

 

The following code is included in frame 1 of a Movie Clip object, with instance name myButton3.   (To attach javascript, I wrapped this Movie Clip around a basic button with instance name baseButton)

//update button used for navigation
this.updateButton = function(targetFrameNum, newText, visibility = true){ 
	this.visible = visibility; 
	this.baseButton.label.text = newText;	
	this.addEventListener("click", function(){exportRoot.gotoAndPlay(targetFrameNum - 1)}.bind(exportRoot), {once: true});  //only clickable once.
}.bind(this);

 

Unfortunately I am having issues with calling updateButton from the main timeline.  I think the function is not declared until after the 1st frame of myButton3 executes, so I am getting errors about this.myButton3.update() being undefined. 

Is there a better way to declare the updateButton member function to make it easily callable from the main timeline?

TOPICS
Other

Views

30

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
Jul 04, 2020 0
kglad LATEST
Adobe Community Professional ,
Jul 05, 2020

Copy link to clipboard

Copied

wait until the needed object exists (eg, by putting this.myButton3.etc in a function called from the timeline/frame where this.updateButton is defined).

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...
Jul 05, 2020 0