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

Timeline control (I think)

Participant ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

I have six symbols on the stage. When a user clicks each, I want it to lose most of its opacity. As a beginner, it seems like there are many ways to acheive this, but I'm not sure which way to go, and so far, haven't been able to do it. Do you get the transparency effect on separate timelines for each object or on the main timeline, or is it easier through js? Some basic setup advice would be appreciated.

TOPICS
How to

Views

777

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 , Mar 31, 2021 Mar 31, 2021

no, that's irrelevant.

 

use:

 

this.dimmerA=["Mer_dimmer", "Jag_dimmer", "Cam_dimmer", "Mia_dimmer", "BM_dimmer", "Lex_dimmer"];

for(var i=0;i<6;i++){
this[this.dimmerA[i]].addEventListener("click",f.bind(this));
}
function f(e){
createjs.Tween.get(e.currentTarget).to({alpha:.1}, 1000);

}

-----------------------------------------------------------------------------------------------------------------------------------------

or use:

 

 

 

this.dimmerA=[this.Mer_dimmer, this.Jag_dimmer, this.Cam_dimm

...

Votes

Translate

Translate
Community Expert ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

for others that don't want to download, the fla contains code from the first message:

 

for(var i=0;i<6;i++){
this["symbol_"+i].addEventListener("click",f.bind(this));
}

function f(e){
createjs.Tween.get(e.currentTarget).to({alpha:.1}, 1000);
}

 

this is all that's required to create fade-outs for 6 movieclips with instance names symbol_0, symbol_1,...,symbol_5

 

--------------------------------------------------------------------------------------------------------------------------------------------------

 

and this is a good example of how thoughtful name assignments can simplify coding.  the coding can still be done with less thoughtful name choices, but it adds complications.

 

and if the op had 10,000 movieclip buttons, the code wouldn't be any more complicated or lengthy (though adding another 9,994 movieclips to the stage and assigning instance names would be time-consuming):

 

for(var i=0;i<10000;i++){
this["symbol_"+i].addEventListener("click",f.bind(this));
}

function f(e){
createjs.Tween.get(e.currentTarget).to({alpha:.1}, 1000);
}

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
Participant ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

In your example, there is one symbol with six different instances. In mine, there are six different symbols (because they are all different images converted to symbols). Is that why this isn't working for me?

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 ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

no, that's irrelevant.

 

use:

 

this.dimmerA=["Mer_dimmer", "Jag_dimmer", "Cam_dimmer", "Mia_dimmer", "BM_dimmer", "Lex_dimmer"];

for(var i=0;i<6;i++){
this[this.dimmerA[i]].addEventListener("click",f.bind(this));
}
function f(e){
createjs.Tween.get(e.currentTarget).to({alpha:.1}, 1000);

}

-----------------------------------------------------------------------------------------------------------------------------------------

or use:

 

 

 

this.dimmerA=[this.Mer_dimmer, this.Jag_dimmer, this.Cam_dimmer, this.Mia_dimmer, this.BM_dimmer, this.Lex_dimmer];

for(var i=0;i<6;i++){
this.dimmerA[i].addEventListener("click",f.bind(this));
}
function f(e){
createjs.Tween.get(e.currentTarget).to({alpha:.1}, 1000);

}

 

-----------------------------------------------------------------------------------------------------------------------------------------

 

or rename your dimmer instance as suggested in the first message and use the code from the first message

 

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
Participant ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Thanks kglad. This is still a bit hazzy to me, but at least it's working. I appreciate it.

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 ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

LATEST

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