-
[MX04] newbie event help
I'm new to all this. I've got a couple pictures converted to movie clips. I've got thumbnails of each that work as buttons for the corrosponding pics. what i want to do is, each time a thumb is clicked, the last picture fades out, and the new pic fades in. my question is, how do i tell my movie clip that's fading in to wait until the last pictures done fading out?
-
Senior Member
what i would do is:
set a variable currentPic to store the current picture MC
code: on(release) { //for the thumbnail
_root.currentPic.onEnterFrame=function() {
this._alpha-=5;
if(this._alpha<=0) {
this.onEnterFrame=function(){};
_root.currentPic=_root.pic4 //change to the corresponding pic for the thumbnail
_root.currentPic.onEnterFrame=function() {
_root.currentPic._alpha+=5;
if(_root.currentPic._alpha>=100) {
_root.currentPic.onEnterFrame=function(){};
}
}
}
}
}
sorry about the many, many levels of indentation. There are many methods that seem much simpler, but i prefer this one because it can all be contained within one event without having to set too many variables.
Unfortunately im not on a pc with flash at the moment so i've just hand coded this and i can't validate this, but if it doesnt work let me know and i'll gladly take another look.
Last edited by DrDoom; 07-26-2006 at 09:53 AM.
-
Senior Member
which is a very interesting solution and def/ one I wouldn't have thought of, which is why they say variety's the spice of whatever. However, if you have a problem using onEnterFrame functions, which many of us w/ single-frame websites do, you might need to explore other possibilities involving (shudder) the dreaded INTERVAL. Intervals tell functions to run every so often (as specified) and keep calling that function until they're deleted. Always name your intervals something simple and path them to the _root so you can get rid of them easy and not have them pile up function after function on you.
In this case, since you're not loading the pix externally, you just have to wait for one to fade for the next to show up...
The best alternate method here would be an interval that waited for the _alpha on the clip to be set to zero. Something like:
Code:
crappyPix.onPress = function() {
_root.fadeIntVar = setInterval(fadeInterval,100,this);
alphaFade(this);
}
function alphaFade(mc) {
mc._alpha -= 10;
}
fadeInterval = function(mc) {
if (this.mc._alpha <= 9) {
clearInterval(_root.fadeIntVar);
//whatever the function is to fade in the next picture goes here.
} else {
alphaFade(this.mc);
}
}
Last edited by joshstrike; 07-26-2006 at 10:34 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|