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

changing the alpha of a movieclip

New Here ,
Dec 07, 2020 Dec 07, 2020

Copy link to clipboard

Copied

Hello,  (using adobe animate)

How do I change the alpha of one movieclip by clicking on another movieclip ?

One movieclip is a button that is supposed to change the other movieclip's transparency.

 

How do I write the code so each time when I click the button, the other movieclip's tranparency changes from 100 to 50, then from 50 to 0, and then back again to 50, then to 100?

 

Please help me as soon as possible, thank you so much 

TOPICS
ActionScript , Code , How to

Views

232

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 ,
Dec 08, 2020 Dec 08, 2020

Copy link to clipboard

Copied

if html5:

 

this.toggle=-1;

this.control_mc.addEventListener("click",controlF.bind(this));

function controlF(){

this.target_mc.alpha += .5*this.toggle;

if(this.target_mc.alpha<.1 || this.target_mc.alpha>.9){

this.toggle*= -1;

}

}

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
Explorer ,
Dec 17, 2020 Dec 17, 2020

Copy link to clipboard

Copied

LATEST

If you are using AS3, a variable can help you control the code: See this example:

 

// AS3

var alphaProgress: Boolean = true;

mc1.addEventListener(MouseEvent.CLICK, fnAlpha);
function fnAlpha(event: MouseEvent): void {

if ((alphaProgress == true) && (mc2.alpha > 0)) {
mc2.alpha -= 0.5;
trace(mc2.alpha);
} else if (mc2.alpha <= 0.5) {
alphaProgress = false;
mc2.alpha += 0.5;
trace(mc2.alpha);
if (mc2.alpha == 1) {
alphaProgress = true;
}
}
}

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