LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 


  #1  
Old 05-28-2004, 03:25 PM
chris12295 chris12295 is offline
Registered User
 
Join Date: Sep 2002
Posts: 35
Rep Power: 0
chris12295 is on a distinguished road
only fade on mouse over

I have a mc that fades when you mouse over it. trouble is, it fades when you move the mouse over other parts of the stage. i only want it to fade if the mouse is over the mc. any ideas? here is my code for fading:

Actionscript:
onClipEvent(load) {
	//Makes variable to store inertia.
	_root.mosx = 0;
	//Makes variable to store inertia.
	_root.mosy = 0;
	_root.inertia = 5;
	_root.ratioX = 206/100;
	_root.ratioY = 138/100;
}
onClipEvent(enterFrame) {
	//Takes '_root.mosx' and subtracts by the _xmouse mouse position to yield the difference.
	_root.difx = _root.mosx - _root.fader._xmouse;
	//Takes '_root.mosy' and subtracts by the _ymouse mouse position to yield the difference.
	_root.dify = _root.mosy - _root.fader._ymouse;
	//Subtracts the total of the _xmouse position and '_root.mosx' and _root.inertia determines the speed of the effect.
	_root.mosx -= _root.difx / _root.inertia;
	//Subtracts the total of the _ymouse position and '_root.mosy' and _root.inertia determines the speed of the effect.
	_root.mosy -= _root.dify / _root.inertia;
	//Used to control the _alpha setting of 'graphic1' with dependency of the mouse position and inertia.
	_root.fader.graphic1._alpha = (_root.mosx / _root.ratioX) - (_root.mosy / _root.ratioY);
	//Used to control the _alpha setting of 'graphic2' with dependency of the mouse position and inertia.
	_root.fader.graphic2._alpha = 100 - (_root.mosx / _root.ratioX) - (_root.mosy / _root.ratioY);
	//Used to control the _alpha setting of 'graphic3' with dependency of the mouse position and inertia.
	_root.fader.graphic3._alpha = (_root.mosy / _root.ratioY) - 100 + (_root.mosx / _root.ratioX);
	//Used to control the _alpha setting of 'graphic_root.ratio' with dependency of the mouse position and inertia.
	_root.fader.graphic4._alpha = (_root.mosy / _root.ratioY) - (_root.mosx / _root.ratioX);
}
  #2  
Old 06-02-2004, 12:01 AM
Scottae's Avatar
Scottae Scottae is offline
God Moderator
 
Join Date: Oct 2003
Location: United States
Posts: 6,532
Rep Power: 16
Scottae is on a distinguished road
Source Example

Try copying and pasting this code into the first frame of the main timeline of a new Flash MX movie and test it out to see if this is the effect you want:

Actionscript:
// create clip and store a reference to it in variable 'c'
var c = _root.createEmptyMovieClip("my_mc", 0);

// width of clip 'c'
var w = 50;

// draw clip 'c'
with (c) {
	beginFill(0xFF0000, 100);
	lineStyle(0, 0x000000, 100);
	lineTo(w, 0);
	lineTo(w, w);
	lineTo(0, w);
	lineTo(0, 0);
	endFill();
}

// create enterframe event that constantly checks and updates status of 
// the clip 'c'
c.onEnterFrame = function() {
	
	// how fast clip fades (adjustable)
	var speed = 10;
	
	// if 'fade' is true, and if alpha is greater than zero, the subtract
	// 'speed' from current alpha value
	if (this.fade) {
		if (this._alpha > 0) {
			this._alpha -= speed;
		}
	// else if 'fade' is false, and if alpha is less than 100, the add
	// 'speed' to current alpha value
	} else {
		if (this._alpha < 100) {
			this._alpha += speed;
		}
	}
};

// rollover and rollout events that change the fade variable on the
// clip 'c' to either true or false
c.onRollOver = function() {
	this.fade = true;
};
c.onRollOut = function() {
	this.fade = false;
};
__________________
Our greatest glory is not in never falling but in rising everytime we fall. - Confucius

Blog | Shared Items
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
using mouse to choose array of objects in game stevor Newbies 3 08-11-2008 07:13 PM
positioning image with respect to mouse release within textfield ajayk Flash MX 2004 5 08-05-2005 02:32 PM
Interesting Question.........maybe...... Av General Flash 86 09-24-2002 10:11 AM
mouse up, down, and everything somerovi Newbies 2 04-05-2002 11:06 AM
Check mouse position in specific frame yan Advanced Flash 1 06-24-2001 12:22 AM




All times are GMT. The time now is 11:39 PM.