WHAT IS WRONG WITH ME!!??
OK, trying to fade out a button through a function. I’ve done this before but I’m tired and it’s just not happening.
OK, there’s a button named “button” and a movieclip named “fadeThis”. The first frame of the root has the following code in it:
fading = function(image) {
_root[image]._alpha -= 5;
}
And the button, “button”, has the following code in it:
on (release) {
fader = setInterval(_root.fading,10,fadeThis);
}
So WHY does the function fade the entire screen (“fadeThis” AND “button”)??
Thanks
system
August 20, 2004, 6:42am
2
Don’t crosspost, one forum should be enough;)
scotty(-:
system
August 20, 2004, 12:01pm
3
Sorry. Won’t happen again.
So does anyone actually have the answer to my problem or another way I should do it?
system
August 21, 2004, 3:33pm
4
Try using an onEnterFrame handler to repeat the alpha diminish-[insert rest of word here].
{instance_name}.onRelease = function(){
auxmc = this._parent.createEmptyMovieClip("aux",999);
auxmc.onEnterFrame = function(){
this._parent.{instance_name}._alpha -= 2;
if(this._parent.{instance_name}._alpha <=0) delete this.onEnterFrame;
}
}
system
August 21, 2004, 3:43pm
5
Cheers, that’s great. But is it really necessary to get as complicated as that? It’s just that the whole thing works but it fades EVERYTHING out rather than just the graphic I want to fade out.
If I write it like this:
on (release) {
fader = setInterval(function {_root.fadeThis._alpha -= 5;},10);
}
It works perfectly. But I don’t want to do it like this, I want to use a functino that can have an image name passed to it. It just feels like I’m calling the image in the function wrong or something.
Thanks
system
August 21, 2004, 4:11pm
6
IMO it’s better to use an onEnterFrame handler. With setInterval there’s the whole hassle with the scopes and the interval clearing and whatnot, an onEnterFrame handler is so much easier to use.
system
August 21, 2004, 4:44pm
7
trundrumbalind:
Cheers, that’s great. But is it really necessary to get as complicated as that? It’s just that the whole thing works but it fades EVERYTHING out rather than just the graphic I want to fade out.
If I write it like this:
on (release) {
fader = setInterval(function {_root.fadeThis._alpha -= 5;},10);
}
It works perfectly. But I don’t want to do it like this, I want to use a functino that can have an image name passed to it. It just feels like I’m calling the image in the function wrong or something.
Thanks
change your function to
fading = function (image) {
image._alpha -= 5;
if (image._alpha<0) {
clearInterval(fader);
}
};
system
August 21, 2004, 5:46pm
8
on (release) {
fader = setInterval(_root.fading,10,“fadeThis”);
}
that might work a little better
system
August 21, 2004, 10:47pm
9
Good MAN!!!
That’s it. Muchly appreciated.