Jump to content
xisto Community
Two Gun Charley

Mouse Over Alpha Fade Flash CS3

Recommended Posts

Hey team,New to the forums and new to Flash. I'm trying to work out what script I need to use in order to make a movie clip (a grey square if it matters) change alpha qualities when you roll the mouse over it. I also want it to stop and fade back to it's original form when you move the mouse off it. I've got it working just using a button symbol but when I take the mouse of it just jumps straight back to the original form (ie. no 'fade out') and it also repeats itself. I've googled it, and done a search on the forums. I'm sure it's a simple solutions. Thanks in advance for your help!

Share this post


Link to post
Share on other sites

Some on that effect here

Basically you just use setInterval to call a function every now and then.

In more depth ->
Have a function which is called by setInterval:
->Lowers the alpha
->Clear the interval is the alpha is low enough
Have another function that increases the alpha instead
When you roll over, call setInterval for decreasing alpha, clear interval for increasing alpha
When you roll out, clear the interval for decreasing alpha and set interval for increasing alpha

Code (I have the object named 'ob', ideally you would use this._alpha except I couldn't get it working and I've got to go now..)

onClipEvent (load) {	function DecreaseAlpha ()	{		_root.ob._alpha -= 2;		if (_root.ob._alpha <= 50)		{			clearInterval (DecreaseAlphaInterval);		}	}	function IncreaseAlpha ()	{		_root.ob._alpha += 2;		if (_root.ob._alpha >= 100)		{			clearInterval (IncreaseAlphaInterval);		}	}}on (rollOver) {	DecreaseAlphaInterval = setInterval (DecreaseAlpha, 40);	clearInterval (IncreaseAlphaInterval);}on (rollOut) {	IncreaseAlphaInterval = setInterval (IncreaseAlpha, 40);	clearInterval (DecreaseAlphaInterval);}

Edited by Nabb (see edit history)

Share this post


Link to post
Share on other sites

Thanks for that man, really appreciate it. Works sweet as!

Got an even more new jack question now. I'm trying to get the movie clips that I added that script to, to now act as buttons and link to the first frame on a few other scenes.

So I tryed to add this to the top of the actions pannel (above that alpha fade script);

on (release) {gotoAndPlay("scene1",1);}

But no dice. Any ideas?

Thanks again man. Struggling threw this a wee bit, as you can tell.

Share this post


Link to post
Share on other sites

I think that's a problem of scope (it's a killer when you're starting flash if you don't have programming experience). Changing it to _root.gotoAndPlay should suffice. If you leave the _root out, I think it would try to make the button go to frame 'scene1'.

Share this post


Link to post
Share on other sites

I like to put all my actions on frames instead of putting them on buttons or clips. It makes the .fla look clean and the actions easier to follow.
This is the code I used on the second frame:

stop();function DecreaseAlpha (){    _root.button._alpha -= 2;    if (_root.button._alpha <= 50){        clearInterval (DecreaseAlphaInterval);    }};function IncreaseAlpha (){    _root.button._alpha += 2;    if (_root.button._alpha >= 100){        clearInterval (IncreaseAlphaInterval);    }};_root.button.onRollOver = function(){    DecreaseAlphaInterval = setInterval (DecreaseAlpha, 40);    clearInterval (IncreaseAlphaInterval);}_root.button.onRollOut = function(){    IncreaseAlphaInterval = setInterval (IncreaseAlpha, 40);    clearInterval (DecreaseAlphaInterval);}_root.button.onRelease = function(){    gotoAndStop(1);}

It looks a lot like Nabb's code because I copied his code and modified it :)
Here's my *fla if you need it: http://110mb.com/404.php (Right Click, Save As)
It may help to look at a live, working example rather than at a code.

Share this post


Link to post
Share on other sites

Yeah cheers man, put the navigation actions on a frame in a function and it works sweet as.

Got the site live. You can check it out here; http://www.bairstow.co.nz/david/

It's working sweet as, just some crazy stuff happens with the alpha fades when you return to the opening scene. If you click the second bar, then the 'take me back' button, the second bar then fades out to background colour.

Anyone know what all that's about? You can download the .fla file here http://forums.xisto.com/no_longer_exists/

Thanks in advance guys.

Share this post


Link to post
Share on other sites
Replying to Two Gun CharleyHello there, I,m from the Netherlands. I want the fade in/out action on mouse over/off on a silhouet of a person.So when you open the page you see the grey silhouet, but when you go over it with your mouse it will SLOWLY appear in full colour.Can you tell me (please step by step) how to make such an action?Lots of thanks...Greetz Ronald (Netherlands) -reply by ronald

Share this post


Link to post
Share on other sites

It seems to work fine with Mozilla Firefox 3, but when I use Internet Explorer 7 every bar blends into the background when I click 'take me back'.I'll take a look at the .fla , but I can't promise I'll be able to help.

Share this post


Link to post
Share on other sites
multiple actions on frameMouse Over Alpha Fade

I would also like to know how to use Einreaper's method for multiple buttons. When I try to duplicate the code and change the button names it doesn't work. Please help. I have a feeling it has to do with how the code is closed within.

I have several buttons (button1, button2, button3, etc) and would like to apply the alpha rollover/rollout to all the buttons and code it all on a single frame.

 Thank you.

-reply by theloomis

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.