all groups > flash actionscript > october 2006 >
You're in the

flash actionscript

group:

Auto Fade In/Out effect in actionscript...


Auto Fade In/Out effect in actionscript... IndioDoido
10/28/2006 10:34:38 PM
flash actionscript: Hi,
I'm trying to make a mc with a shape fade in and out when someone clicks a
button. No problem here...my issue is that i what to use actionscript to fade
in and out continuasly.
Exmp.:

iMais.onEnterFrame = function()
{
this._rotation += 10;
this._alpha -= 5;
}

This code makes the simbol rotate and fade out, but i what it to fade back in,
and go on like this continuously.
I tryed to do it with an if condition, but it didn't work, I'm not good at
coding :-(

Can anyone help me on this...
Re: Fade In/Out loop effect in actionscript DJ Sick Nick
10/29/2006 12:03:56 AM
how about:
iMais.onEnterFrame = function ()
{
iMais._rotation += 10;
if (iMais._alpha <= 5) {
iMais._alpha += 5;
} else {
iMais._alpha -= 5;
}
};

try that out. If it doesnt work, play arouns with "if" statements.
Re: Fade In/Out loop effect in actionscript kglad
10/29/2006 1:08:08 AM
that won't work. iMais will fade between 2 _alphas that differ by 5 and are
both between 0 and 10.

try:



iMais.onEnterFrame = function() {
this._rotation += 10;
if (this._alpha>=100) {
this.fade = -1;
} else if (this._alpha<=0) {
this.fade = 1;
}
this._alpha += this.fade*5;
};
Re: Fade In/Out loop effect in actionscript DMennenoh **AdobeCommunityExpert**
10/29/2006 9:58:14 AM
[quoted text, click to view]
{
iMais._alpha -= 5;
} else
{
iMais._alpha += 5;


Your version doesn't work because of the way you're testing. If the alpha
starts at 0 it will increase by 5 until it gets >= 100... But, next time
through since it is 100 - 5 will be subtracted, making the alpha 95... Next
time in the loop alpha is no longer >= 100 and 5 will be subtracted... you
are now stuck oscillating between 95 and 100.

HTH

--
Dave -
Head Developer
www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

Re: Fade In/Out loop effect in actionscript DMennenoh **AdobeCommunityExpert**
10/29/2006 12:26:06 PM
[quoted text, click to view]

That last part should be ... and 5 will be added... you are now stuck
oscillating between 95 and 100.


--
Dave -
Head Developer
www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

Re: Fade In/Out loop effect in actionscript IndioDoido
10/29/2006 1:56:50 PM
hey DJ and kglad, thanx for the fast reply.

[quoted text, click to view]

iMais.onEnterFrame = function ()
{
iMais._rotation += 10;
if (iMais._alpha >= 100)
{
iMais._alpha -= 5;
} else
{
iMais._alpha += 5;
}
};

But it didn't work, and I don't understand why!?!

Then I tryed your version, kglad, and it worked nicely :-D

But I would like to understand why doesn't my version work?
Re: Fade In/Out loop effect in actionscript IndioDoido
10/30/2006 9:44:34 PM
AddThis Social Bookmark Button