View Full Version : Fading In/Out Methods?

07-12-2001, 08:42 AM
I'm new to Flash still, but learning a lot very quickly. I have an in-depth javascript background that makes all the actionscript stuff a snap to understand. Having done a lot of work in Photoshop has also greatly helped with understanding Flash 5's user interface. I look at Flash as the mergance of coding and design, and it being that way makes for a many aproaches to the same task. So I imagine I will be coming here often to collect opinions on which way is best to achieve a desired effect. :)

The effect I am trying to achieve right now is a simple fading effect. I have messed with the alpha effect using keyframes in a movie symbol, but it seems too repetitive and can't be reused. I know that in javascript/dhtml I was able to write a function that could be reused by different objects on the page, and would fade them smoothly to whatever opacity I specified. So I guess what I am asking is:

Is it possible to use an actionscript to dynamically fade specified symbols to specified alpha levels smoothly?

Also, is there a better way to go about achieving this fade in/out effect that I may not have relised yet?

Thanks in advance.

07-12-2001, 01:26 PM
use an onClipEvent (enterframe) loop , set property, and 3 variables. 1 Booleen which specifies if we want to alpha tween anything at the moment. 1 string which specifies the name of the object to tween. 1 number which is the value to tween to.... try it yourself, and reply if you can't get it working.

08-05-2001, 09:01 PM
I can't seem to figure it out on my own. I learn best by example though, so anyone feel up to showing me an actionscript example of how I could go about creating this fading effect?

What I am trying to do, is make a button smoothly fade in when the mouse hovers over it, and have it fade back out to a certain level when the mouse is not over it. It doesn't have to be a button symbol, just needs to be able to go to a certain scene/frame when clicked on. I want to use alpha to do this because I want objects behind the button to show through when it is faded out.

I found a good example of fading using this script:

onClipEvent (load) {
val = 100;

onClipEvent (enterFrame) {
if (val >= 100) addval = -5;
if (val <= 0) addval = 5;

val += addval;

this._alpha = val;

But I can't seem to figure out how to control it. IT IS SOOO FRUSTRATING BEING NEW! I know I will look back on all this someday and think how crappy I was and how simple all this really is, kinda like I do now with Javascript.

08-06-2001, 02:47 AM
Here's some code I've used.

function fadeIn(MC){

with (MC){
_alpha += _alpha/2

To explain the above code . . . you would use the .hitTest() method of a movieclip object (search the forums or look in tutorials for examples on that) to see if your mouse is over the specified movieclip. Then you make the following call: fadeIn(this)

from within the clip itself. Alternately, you could pass in the path of the clip (_root.movieclipname). Then, the with() function uses the properties of the movie clip to fade it in. You can vary the /2 to get the desired effect, or even use something like _alpha += 5.

I know this isn't comprehensive, but if you would post any questions, I could go into more depth.

One other suggestion -- look in the tutorials for onClipEvents -- it's the most useful feature of Flash that I've found so far.