movieclip rollover question

Im trying to create a move which ahs the following.

3 movieclips on the stage.

When I rollover "movieclip1", movieclip 2 & 3 fade.
When I rollover "movieclip2", movieclip 1 & 3 fade.
When I rollover "movieclip3", movieclip 1 & 2 fade.

on rollout

When I rollout "movieclip1", movieclip 2 & 3 unfade. (lack of a better term)
When I rollout "movieclip2", movieclip 1 & 3 unfade.
When I rollout "movieclip3", movieclip 1 & 2 unfade.

BUt when I rollover either moveiclip quickly it doesnt look right.

Heres the code I have for Movieclip 1

on (rollOver) {
      if (_root.buttonsupporters._currentframe == 1) {
            _root.buttonsupporters.gotoAndPlay(2);
      } else if (_root.buttonsupporters._currentframe == 10) {
            _root.buttonsupporters.gotoAndStop;
      }
      if (_root.buttonwork._currentframe == 1) {
            _root.buttonwork.gotoAndPlay(2);
      } else {
            _root.buttonwork.gotoAndStop;
      }
      trace(this._currentframe);
}


on (rollOut) {
      if (_root.buttonsupporters._currentframe < 10) {
            _root.buttonsupporters.gotoAndPlay;
      } else {
            _root.buttonsupporters.gotoAndPlay;
      }
      if (_root.buttonwork._currentframe == 20) {
            _root.buttonwork.gotoAndStop(10);
      } else {
            _root.buttonwork.gotoAndPlay(11);
      }
      trace(this._currentframe);
}
Cheryl LanderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
I would specify frames that you want to go to as some of your gotoAndPlay / gotoAndStop methods you are not passing the frame to go to.  i know it may work but by explicitly specifying the frame it lessens that chance that your problem is occurring there.

is the only animation of the button to fade in and out?

are you able to upload your fla for this as i reckon it could be better programmed by controlling the mouse events in a central timeline
0
Antonio EstradaTech Leader / Senior Web DeveloperCommented:
Try this code:

<code snippet>

All of this is assuming your buttons are named "but1", "but2" and "but3" on the stage (as in, on the instance name panel).

It basically just fades out and in the other buttons without the need of having to use gotoAndStop() or gotoAndPlay()

-V
but1.onRollOver = function() {
	this._alpha=100;
	clearInterval(Time);
	Time = setInterval(fadeOut,100,but2,but3);
}
 
but1.onRollOut = function() {
	clearInterval(Time);
	Time = setInterval(fadeIn,100,but2,but3);
}
 
but2.onRollOver = function() {
	this._alpha=100;	
	clearInterval(Time);
	Time = setInterval(fadeOut,100,but1,but3);
}
 
but2.onRollOut = function() {
	clearInterval(Time);
	Time = setInterval(fadeIn,100,but1,but3);
}
 
but3.onRollOver = function() {
	this._alpha=100;	
	clearInterval(Time);
	Time = setInterval(fadeOut,100,but1,but2);
}
 
but3.onRollOut = function() {
	clearInterval(Time);
	Time = setInterval(fadeIn,100,but1,but2);
}
 
function fadeOut(Mc1:MovieClip,Mc2:MovieClip):Void {
	Mc1._alpha-=10;
	Mc2._alpha-=10;
	if(Mc1._alpha<=0) {
		clearInterval(Time);
	}
}
 
function fadeIn(Mc1:MovieClip,Mc2:MovieClip):Void {
	Mc1._alpha+=10;
	Mc2._alpha+=10;
	if(Mc1._alpha>=100) {
		clearInterval(Time);
	}	
}

Open in new window

0
RobOwner (Aidellio)Commented:
to add to what Vulturous has said i would use the Tween class as a more efficient way of doing the tweening.  This will fade out the relevant movieclips from their current fade _alpha and fade them back in from their current _alpha, which would give a nice effect
import mx.transitions.Tween;
import mx.transitions.easing.*;
 
var btn1Tween:Tween = null;
var btn2Tween:Tween = null;
var btn3Tween:Tween = null;
 
 
but1.onRollOver = function() {
    but1._alpha = 100;
	btn2Tween = new Tween(but2, "_alpha", None.easeNone, but2._alpha, 0, 1, true);
	btn3Tween = new Tween(but3, "_alpha", None.easeNone, but3._alpha, 0, 1, true);
}
 
but1.onRollOut = function() {
	btn2Tween = new Tween(but2, "_alpha", None.easeNone, but2._alpha, 100, 1, true);
	btn3Tween = new Tween(but3, "_alpha", None.easeNone, but3._alpha, 100, 1, true);
}
 
but2.onRollOver = function() {
    but2._alpha = 100;
	btn1Tween = new Tween(but1, "_alpha", None.easeNone, but1._alpha, 0, 1, true);
	btn3Tween = new Tween(but3, "_alpha", None.easeNone, but3._alpha, 0, 1, true);
}
 
but2.onRollOut = function() {
	btn1Tween = new Tween(but1, "_alpha", None.easeNone, but1._alpha, 100, 1, true);
	btn3Tween = new Tween(but3, "_alpha", None.easeNone, but3._alpha, 100, 1, true);
}
 
but3.onRollOver = function() {
    but3._alpha = 100;
	btn1Tween = new Tween(but1, "_alpha", None.easeNone, but1._alpha, 0, 1, true);
	btn2Tween = new Tween(but2, "_alpha", None.easeNone, but2._alpha, 0, 1, true);
}
 
but3.onRollOut = function() {
	btn1Tween = new Tween(but1, "_alpha", None.easeNone, but1._alpha, 100, 1, true);
	btn2Tween = new Tween(but2, "_alpha", None.easeNone, but2._alpha, 100, 1, true);
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Cheryl LanderAuthor Commented:
Ive tried your solution. works great, but the rollover seems to take a while.

im currently running at 30fps but it still seems very slow.
0
Antonio EstradaTech Leader / Senior Web DeveloperCommented:
Which solution are you using?

If it's the one I proposed, you can safely change it to this:

<code snippet>

It's quicker since it's called every 20 milliseconds. If you're using tagit's solution however, you should try this:

 
but1.onRollOver = function() {
    but1._alpha = 100;
        btn2Tween = new Tween(but2, "_alpha", None.easeNone, but2._alpha, 0, .2, true);
        btn3Tween = new Tween(but3, "_alpha", None.easeNone, but3._alpha, 0, .2, true);
}
 
As in, changing the "1" to ".2" thus moving it from a one second animation to a 20 milliseconds animation.

-V
but1.onRollOver = function() {
	this._alpha=100;
	clearInterval(Time);
	Time = setInterval(fadeOut,20,but2,but3);
}
 
but1.onRollOut = function() {
	clearInterval(Time);
	Time = setInterval(fadeIn,20,but2,but3);
}
 
but2.onRollOver = function() {
	this._alpha=100;	
	clearInterval(Time);
	Time = setInterval(fadeOut,20,but1,but3);
}
 
but2.onRollOut = function() {
	clearInterval(Time);
	Time = setInterval(fadeIn,20,but1,but3);
}
 
but3.onRollOver = function() {
	this._alpha=100;	
	clearInterval(Time);
	Time = setInterval(fadeOut,20,but1,but2);
}
 
but3.onRollOut = function() {
	clearInterval(Time);
	Time = setInterval(fadeIn,20,but1,but2);
}
 
function fadeOut(Mc1:MovieClip,Mc2:MovieClip):Void {
	Mc1._alpha-=10;
	Mc2._alpha-=10;
	if(Mc1._alpha<=0) {
		clearInterval(Time);
	}
}
 
function fadeIn(Mc1:MovieClip,Mc2:MovieClip):Void {
	Mc1._alpha+=10;
	Mc2._alpha+=10;
	if(Mc1._alpha>=100) {
		clearInterval(Time);
	}	
}

Open in new window

0
Cheryl LanderAuthor Commented:
HI Ive used information from both reponses Vulturous: and tagit.

The tagit solution seemed to run much smoother, and Ive incoporated the 0.2 option as provided by vultourous.

Thanks guys.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.