Numerous ending }}}}}}}

New Here ,
May 17, 2020 May 17, 2020

Copy link to clipboard

Copied

Can this be consolidated without adding numerous }}}}} when closing the code?

 

var _this = this;
stage.enableMouseOver(3);
this.front_btn.addEventListener("mouseover", buttonF.bind(this));
function buttonF(){
this.mytext1.text = "Frontal Bone";
this.front_btn.addEventListener("mouseout", buttonF.bind(this));
function buttonF(){
this.mytext1.text = "";
this.nasal_btn.addEventListener("mouseover", buttonF.bind(this));
function buttonF(){
this.mytext1.text = "Nasal Bone";
this.nasal_btn.addEventListener("mouseout", buttonF.bind(this));
function buttonF(){
this.mytext1.text = "";
this.frontal_sinus_btn.addEventListener("mouseover", buttonF.bind(this));
function buttonF(){
this.mytext1.text = "Frontal Sinus";
this.frontal_sinus_btn.addEventListener("mouseout", buttonF.bind(this));
function buttonF(){
this.mytext1.text = "";
this.cg_btn.addEventListener("mouseover", buttonF.bind(this));
function buttonF(){
this.mytext1.text = "Crista Gali";
this.cg_btn.addEventListener("mouseout", buttonF.bind(this));
function buttonF(){
this.mytext1.text = "";
}}}}}}}};

Thank you in advance!

 

Views

404

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
community guidelines
Adobe Community Professional ,
May 17, 2020 May 17, 2020

Copy link to clipboard

Copied

Hi.

 

All this nesting is certainly not necessary.

 

You can define the functions and add the listeners in the same context/level.

 

Something like this:

var _this = this;

function mouseOverHandler0()
{
	_this.text0.text = "mouse over text 0";
}

function mouseOutHandler0()
{
	_this.text0.text = "mouse out text 0";
}

function mouseOverHandler1()
{
	_this.text1.text = "mouse over text 1";
}

function mouseOutHandler1()
{
	_this.text1.text = "mouse out text 1";
}

stage.enableMouseOver(3);

this.yourButton0.addEventListener("mouseover", mouseOverHandler0);
this.yourButton0.addEventListener("mouseout", mouseOutHandler0);

this.yourButton1.addEventListener("mouseover", mouseOverHandler1);
this.yourButton1.addEventListener("mouseout", mouseOutHandler1);

 

Please let us know exactly what you want to achieve.

 

Regards,

JC

 

 

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
community guidelines
Adobe Community Professional ,
May 17, 2020 May 17, 2020

Copy link to clipboard

Copied

I'd like to verify that it's not nesting function declarations seven levels deep that's bothering you, but rather it's literally just the row of closing braces that you don't like the look of.

 

I'm having a hard time imaging how this code would even behave. You have eight event handler functions with the exact same name, and it looks like... triggering them adds the next one in the sequence one by one? That can't be intended behavior.

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
community guidelines
New Here ,
May 18, 2020 May 18, 2020

Copy link to clipboard

Copied

LATEST
Hi JC,
Thank you so much for your response! I knew there was too much nesting and
wanted to understand how to consolidate. You've been extremely helpful and
I am grateful for your response.

I will try your consolidation. Thank you again!



W. Bruce Howerton, Jr. DDS, MS
Oral and Maxillofacial Radiologist
p-(919) 534-7000
f-(919)-534-7003
www.carolinaomfimaging.com

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