?
Solved

movieclip rollover question

Posted on 2008-02-05
6
Medium Priority
?
307 Views
Last Modified: 2010-04-03
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);
}
0
Comment
Question by:Cheryl Lander
  • 2
  • 2
  • 2
6 Comments
 
LVL 43

Expert Comment

by:Rob
ID: 20827062
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
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 20827583
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
 
LVL 43

Accepted Solution

by:
Rob earned 1400 total points
ID: 20828112
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Cheryl Lander
ID: 20847197
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
 
LVL 18

Assisted Solution

by:Antonio Estrada
Antonio Estrada earned 600 total points
ID: 20851273
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
 

Author Comment

by:Cheryl Lander
ID: 20854087
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

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question