how to create a fade in AS3


#1

Okay so i got a movie clip with a few graphics. I want to use as3 to create a fade in and fade out effect i can put into condition statements.

I tried:

if (john_btn.alpha=1){

trace(“Done”);
}else{
john_btn.alpha=john.alpha+.01;
}

What am i missing?

Thanks


#2

Use Tween class or increase/decrease the alpha value of the movie clip step by step on each frame.


#3
if (john_btn.alpha=1){

trace(“Done”);
}else{
john_btn.alpha=john.alpha+.01;
}

And be careful while using conditional statements. Use ‘==’ operator instead of ‘=’

if (john_btn.alpha ==1)


#4
if (john_btn.alpha != 1){
     john_btn.alpha += .01;
 }

All of that needs to be wrapped in something that’s going to make it repeat. An enterFrame event or a timer event.


#5

i could use some help with this… and would pay i guess…

its simple.

I got 4 buttons… when you click on each one some words need to fade in with a picture that if you roll over it it changes…

if you click on another button i need it to fade out from the current scene to and fade into the words and picture that were clicked on…

signalr32@gmail.com

I got the file and everything layed out very nicely…

Let me know…

Thank you


#6

i am focused on AS3 development.


you can use alpha tween:


import fl.transitions.;

import fl.transitions.easing.
;



var imageMcTween = new ween(john_btn,‘alpha’,None.easeNone,0,1,2,true);


0: start alpha

1: end alpha

2: time for the tween, It is 2 seconds.

you can modify these three parameters.


#7

what about getting the mc’s current alpha and then tweening to a new alpha value?


#8

i’ve been having some trouble making a fade in and out function…PLEASE HELP!

movie clip ‘mcontent’ holds: frames with labels

when someone clicks a button in the scene i want the action script to fade out the movie clip and gotoAndPlay the fame with that label and then fade the mcontent movie clip back in…

here is my as3:

import flash.utils.*;

stop();

function changePage(event:MouseEvent):void{
if(event.target.name==‘aboutButton’){
//fade out mcontent
mcontent.gotoAndStop(‘about’);
//fade in mcontent
trace(‘about worked’);
} else if(event.target.name==‘menuButton’){
//fade out mcontent
mcontent.gotoAndPlay(‘menu’);
//fade in mcontent
trace(‘menu worked’);
} else if(event.target.name==‘eventsButton’){
//fade out mcontent
mcontent.gotoAndPlay(‘events’);
//fade in mcontent
trace(‘events worked’);
} else if(event.target.name==‘galleryButton’){
//fade out mcontent
mcontent.gotoAndPlay(‘gallery’);
//fade in mcontent
trace(‘gallery worked’);
} else if(event.target.name==‘contactButton’){
//fade out mcontent
mcontent.gotoAndPlay(‘contact’);
//fade in mcontent
trace(‘contact worked’);
} else if(event.target.name==‘ummbalogo’){
//fade out mcontent
mcontent.gotoAndStop(‘blank’);
//fade in mcontent
trace(‘logo worked’);
}
}

ummbalogo.addEventListener(MouseEvent.CLICK,changePage);
aboutButton.addEventListener(MouseEvent.CLICK,changePage);
menuButton.addEventListener(MouseEvent.CLICK,changePage);
eventsButton.addEventListener(MouseEvent.CLICK,changePage);
galleryButton.addEventListener(MouseEvent.CLICK,changePage);
contactButton.addEventListener(MouseEvent.CLICK,changePage);

THANKSS!