Why does this happen?

Hey all,

I have built a little script for gradual alpha fading in and fading out on RollOver and RollOut.

on (rollOver) {
_root.onEnterFrame = function() {
_root.mvWhathandset._alpha += (100-this.mvWhathandset._alpha)/20;
};
}

on (rollOut) {
_root.onEnterFrame = function() {
_root.mvWhathandset._alpha += (0-this.mvWhathandset._alpha)/10;
};
}

If you rollover and rollout a single instance it works perfectly. When I place two instances side by side (alterning the instance name for each script obviously) and move the mouse over each of them the script falls to pieces, with one instance stopping the other and generally screwing things up!

Can someone help with this as Ihave tried to solve this problem for hours. I have even experimented with HitTest, but couldnt figure out how to HitTest more than one object…aaarrrgh!

Help please…

thanks in advance,
mecha

Pretty simple. You always use the same onEnterFrame. If the left one fades in, and you rollOver the right one, the left one will fade out but immediately after that you rollOver the right one, so that wil start fading in. Because you use the same onEnterFrame, the left one will stop fading because the other one uses the onEnterFrame.

Here you go :slight_smile:

Thanks Voets,

any suggestions as to sove this problem?

mecha

:thumb:

mecha

Welcome :wink:

Let me make sure I understand this, not much point in it working if I dont learn anything!!

When you added:

_root.[COLOR=red]mvBG.leftbox[/COLOR] .onEnterFrame = function()…

you told Flash to look at the onEnterFrame of the two movieclips you renamed “leftbox” and “rightbox”…correct?

In that case, in future projects if I need to do several onEnterframe commands I could set up some empty MC’s outside the stage and use their “onEnterframe”. Am I getting this?

mecha :tie:

*Originally posted by mecha *
**When you added:

_root.[COLOR=red]mvBG.leftbox[/COLOR] .onEnterFrame = function()…

you told Flash to look at the onEnterFrame of the two movieclips you renamed “leftbox” and “rightbox”…correct?**

Correct.

*Originally posted by mecha *
In that case, in future projects if I need to do several onEnterframe commands I could set up some empty MC’s outside the stage and use their “onEnterframe”. Am I getting this?

Yep. This is an example that uses empty mcs outside the stage. But it’s no use to create new empty ones if there are already other mcs that have no onEnterFrame.