View Full Version : Fading between movie clips
fetimo
March 30th, 2008, 09:50 AM
Hey all,
I've been browsing the net for a few weeks now trying different tutorials and ideas users have for making text fade between each movie clip. i.e. rolling over an image that fades in text and then fades out on rollout. I'm relatively new to as2 (using Flash Prof. 8 but have access to CS3). Any help would be hugely appreciated as it's part of a college project that's due in at the end of the next week! >.<
If you double click any of the faces you'll see that on roll over it goes to the second frame in the movie clip but i just don't know how to make this fade, my friend said to try just running a motion tween changing the alpha but not even this works for reasons unknown to me =/
Basically, the file's 4.35mb so too big for the forum but I've uploaded it to: http://www.megaupload.com/?d=NXGDVFTY
Thanks in advance,
Tim
glosrfc
March 30th, 2008, 12:10 PM
Too big for me to download, but this attachment should give you an idea of how to go about it.
fetimo
March 30th, 2008, 05:15 PM
Hey, thanks for that it looks really good! And seems to be what I need, I'm just having some trouble implementing it into my own project.
Does the container_mc and text_mc have to be in the same frame and if not do you know how to select it from a different frame? Also does the 'this' basically make an empty movie clip? It's all pretty much Greek to me! Sorry for the noobishness, our teacher knows minimum about Flash :/
Thank you,
Tim
glosrfc
March 30th, 2008, 06:14 PM
container_mc, as the name suggests, contains the image and another mc, called text_mc, which holds the text you want to fade in/out. When you rollOver container_mc, the actionscript triggers the fadeIn function and vice versa when you rollOut.
These objects can be in any frame so long as they have instance names that you can target correctly. 'this' is used to reference the container_mc movieclip. In other words, it provides the correct target path to the container_mc regardless of where it's placed in your movie and on which level it resides. You don't have to use it but it avoids the need to hard-code the path and change it everytime you alter your FLA.
fetimo
March 31st, 2008, 12:23 PM
Ahhh clever! I had an inkling it was something like that but just wanted to clarify. Thank you very much will get working on it in a bit and may I just say I believe your signature is the best I've ever seen!
glosrfc
March 31st, 2008, 01:07 PM
Good luck
fetimo
March 31st, 2008, 05:51 PM
Argh this is annoying me so much! Spent about an hour and a bit on it, does this code at least look as if it should work or does it have some fatal errors?
stop();
rohan.onRelease = function () {
gotoAndStop(2);
getURL("../Pages/Members.html")
}
rohan.members._alpha = 0;
fadeAmount = 5;
function fadeIn() {
members._alpha += fadeAmount;
if (members._alpha>=100) {
members._alpha = 100;
members.onEnterFrame = null;
}
}
function fadeOut() {
members._alpha -= fadeAmount;
if (members._alpha<=0) {
members._alpha = 0;
onEnterFrame = null;
}
}
rohan.onRollOver = function() {
rohan.onEnterFrame = fadeIn;
rohan.gotoAndStop(2);
}
rohan.onRollOut = function() {
rohan.onEnterFrame = fadeOut;
rohan.gotoAndStop(1);
}
is all that should be relevant, really sorry about this :(
i got rid of the this thing because multiple movie clips will have to fade different text (making something of a navigation bar-esque thing)
glosrfc
March 31st, 2008, 08:07 PM
Two things I can see straight away:
The onEnterFrame isn't being cancelled in the fadeOut function..it's missing members.
Not sure why you're still switching frames in rohan. There's no need as the fadeIn and fadeOut functions should handle the alpha changes for you without having to resort to any timeline animation.
Oh, and there's a third thing. Because you're not using 'this', you'll have to ensure that your targetting is accurate. My guess is that rohan is the equivalent of the container_mc in my example and members is the equivalent of the text_mc? If so, then you'll have to target the text explicitly, e.g. rohan.members._alpha += fadeAmount and so on.
You mention that you plan on having multiple movieclips fading but that's where 'this' can really help. For example, say you have two movieclips (MC1 and MC2) both of which contain a movieclip (Text) that you want to fade. You would have to duplicate the code for each of the rollOver and rollOut events for both movieclips when it's a lot easier to use 'this'. Instead of:
MC1.Text._alpha += fadeAmount;
blah blah code
MC2.Text._alpha += fadeAmount;
blah blah more code
you'd use:
this.Text._alpha += fadeAmount;
hey, less code!
Hope that makes sense.
fetimo
April 7th, 2008, 11:14 AM
Hey thanks for all the help and sorry it's taken so long to reply
Basically, aforementioned Flash friend looked at it, did some stuff with it and then used his own code from a project he's doing, but I'll look at yours over spring term and get into the in's and out's of it =)
In other news, am going to try and re-design the whole site using CSS instead of frames, not entirely sure how the Flash will work with it as it can't target DIV's can it? But guess I'll cross that bridge when I come to it.
Thank you.
P.S. Yes it did make sense!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.