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
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;
}
}
Copy link to clipboard
Copied
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;
}
}
}