PDA

View Full Version : Static text alpha adjustments


trip96
03-14-2005, 11:45 PM
Hello, I have been making a menu for a site and i wanted to have a logo fade in and the menu text to fade out when the user rolls over the menu text. Then the opposite when it is rolled off the menu text. I have been able to get it to work but it only works for three rolls. then its liek actionscrupt isnt even there anymore. This is a strange problem an di was owndering if anyone had any ideas to help me here is code for one of the menu elements i am using :


//Roll over animations//////////////////////////////////////////////////////////

mcHome.onRollOver = function():Void{
var IntervalHomeO = setInterval(animateHomeO,1)
function animateHomeO():Void{
if (mcHome._alpha > 40){
mcHome._alpha--}
}
var IntervalEh = setInterval(animateEh,1)
function animateEh():Void{
if (mcEh._alpha < 100){
mcEh._alpha ++}
}}


//Roll out animations//////////////////////////////////////////////////////////

mcHome.onRollOut = function():Void{
var IntervalHomeT = setInterval(animateHomeT,1)
function animateHomeT():Void{
if (mcHome._alpha < 100){
mcHome._alpha++}
}
var IntervalEhT = setInterval(animateEhT,1)
function animateEhT():Void{
if (mcEh._alpha > 0){
mcEh._alpha --}
}}

jjbilly
03-15-2005, 05:45 PM
Try clearing your intervals. When your conditional in the animate function fails, call
clearInterval(IntervalHomeO). Eg, your first function should look like this:

function animateHomeO():Void{
if (mcHome._alpha > 40){
mcHome._alpha--}
else
{
clearInterval(IntervalHomeO)
}
}

What I think's probably happening at the moment is that your intervals are stacking up - and so as quick as the _alpha can be incremented, it's being decremented again by an old interval hanging around. Even when you don't have problems like this, it's worth keeping track of and clearing the blighters - otherwise they hang around and crop up as gremlins when you're least expecting them.

Hope this helps.

By the way, when you're posting code, use the red flash icon to wrap your code with AS tags. It formats the code for you and makes it much easier for others to read - see the sticky thread up top.

jjbilly
03-15-2005, 05:47 PM
Just to be clear - you'll need to do something similar in each of your callback functions.