Link to home
Start Free TrialLog in
Avatar of Richiep86
Richiep86

asked on

FLASH CS5.5 - ActionScipt - Bring to front on MouseOver

Hi All,

I have several movieclips in my flash file, when i put my mouse over each movieclip that section of the image expands and changes colour.

The problem i have now is i need whatever element/layer i hover over to be brought to the front. At the moment, If i hover over a section it does expand as it should, however if there is another layer beneath it, the expand happens underneath the other layer.


So, to sum up i need a script which brings what ever layer is hovered over - to the top.

Please see attached image:

Many thanks,
Avatar of Gabriologist
Gabriologist

Hi.

You don't say if you are using actionscript 2 or 3. This matters because they handle this ability in different ways.

AS2
The function is called swapDepths - see some discussion / code here - http://board.flashkit.com/board/showthread.php?618797-SwapDepth-Return-to-Original-Position-Animated-Buttons

AS3
The function is setChildIndex and you can see some code here - http://www.dzone.com/snippets/as3-swapdepths-equivalent
Avatar of Richiep86

ASKER

i believe it is As2.0


heres what i have:

// stops our animation
stop();

// whenever player enters frame, perform the actions between the curly brackets											 
this.onEnterFrame = function(){
	
	// if our zoom is "true", then previous frame (rewind)
	if(zoom == true){
		prevFrame();
	}
}

// when mouse is over this symbol, perform the actions between the curly brackets
this.onRollOver = function(){
	
	// sets zoom as false, contradicting our "if" statement above, so it plays our clip
	zoom = false;
	play();
}

// when mouse is not over this symbol, perform the actions between the curly bracktes
this.onRollOut = function(){
	
	// sets zoom as true thus meeting the requirements of our "if" statement above
	// so it goes to the previous frame of our movie clip
	zoom = true;
}
button_mc.onRollOver = function() {
notepad_mc.setDepthAbove(button_mc)
}
button_mc.onRollOut = function() {
notepad_mc.setDepthBelow(button_mc) 
} 

Open in new window


I am completely new to flash - thanks for the help so far.

I could attach the flash if that helps?
Sure - attaching the fla might be quickest. CS4 or earlier please... (File > Save as... might be needed)

Some people have reported issues with some filetypes and the EE upload system, so the most reliable way is to drop your fla into a zip file before uploading.
I have attached the flash file in cs4 format - thank you for the help quizengine, much appreciated.

If i add an AS will i then need to name all of my movie files? I thought it would be fairly simply to bring the hoverered upon layer to the front - apparently not!

Thanks again
FINALtestcs4.zip
ASKER CERTIFIED SOLUTION
Avatar of quizengine
quizengine
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent!!!!!

Thanks you soo much - cannot fault the support!