Gradually Roll Off Effect!

Hi, trying to create a gradual roll-off effect.
If I had a movie clip called “roll” that gives my roll over roll off effect that says -
On rollover goto and play 2, and on Roll Off it says goto and Play 20 obviously if I rollover the button and then roll off soon after its going to jump, a gradual rolloff effect can be made!

I know its linked to OnClipEvent, if I use onclipevent (previous frame) that only plays 1 frame back though… right?
perhaps I need to put it in a loop…

if anyone can give the code I would use for my example that would be great.

PS. I know somebody posted this recently, but the forum went down and the links to that thread seem to cough cough fà@% up. :ninja:

What is it that the object does when rolled over or rolled off?

well I have several I would like to make gradually Roll off, as I pick throung my work to try and tidy things up.

This particular one was scale in, scale out. ie. englarges on rollover to visable, shrinks to invisable on roll off.

if it matters I am using Flash 5 still. I have a very small monitor, and MX is very clostraphobic. In a couple of months I’ll probably use MX alone, but not until I get a better monitor!

I’m using 5.0 also… don’t worry about it.

:slight_smile:

I would use action script to do everything. No tweening at all. Mind you, the reason I asked was that this does not work in every situation. It might be recomendable not to use action script if you’re going to have a couple of those that can’t transition well. If you only have a couple, they become a distraction to the viewer. If there’s an even mix of both kinds then it’s not too bad.

For scaling, as with movement, we need to adjust the property of the object in question, using a button… Likewise we need the object to continue towards the proper course without disturbing it’s path to that eventual state of being.

Make sure that the movie clip and the button are located in the same timeline. In my example the movie clip has been given an instance name of “scaledClip”.

Now… keep this in mind. If the movie clip has stuff going on on it’s own timeline which makes it’s play head stop, then the onClipEvent on it will stop working until the movie clip starts playing again. If this is the case, then you’ll need to place the movie inside another movie clip.

on the movie clip which will be constantly playing, and located on the same timeline as the button you place this code.


onClipEvent(load){
    trip=1;
    rateOfChange=5;
}
onClipEvent(enterFrame){
    if(trip=1&&_yscale<100){
        this._yscale+=rateOfChange;
        this._xscale+=rateOfChange;
    }else if(trip==0&&_yscale>0){
        this._yscale-=rateOfChange;
        this._xscale-=rateOfChange;
    }
}

the button then has this.


on(rollOver){
    _parent.scaledClip.trip=1;
}
on(rollOut){
    _parent.scaledClip.trip=0;
}

this is it with added alpha code added. Notice in this one I left out all those “this”'s which are really unnecessary in an onClipEvent method.


onClipEvent(load){
    trip=1;
    rateOfChange=5;
}
onClipEvent(enterFrame){
    if(trip=1&&_yscale<100){
        _alpha+=rateOfChange;
        _yscale+=rateOfChange;
        _xscale+=rateOfChange;
    }else if(trip==0&&_yscale>0){
        _alpha-=rateOfChange;
        _yscale-=rateOfChange;
        _xscale-=rateOfChange;
    }
}

the button then has this.


on(rollOver){
    _parent.scaledClip.trip=1;
}
on(rollOut){
    _parent.scaledClip.trip=0;
}

sorry… that aint working yet. I’m trying to figure out what I did wrong

ok… figured it out. I’m addressing it wrong,

this is how it would be if the movie clip were suposed to start out, 0 scale, and 0 alpha and have a button which controled the transition in of the movie clip.

button code

on (rollOver) {
	scaledClip.trip = 0;
}
on (rollOut) {
	scaledClip.trip = 1;
}

mc code

onClipEvent(load){
	trip=1;
	rateOfChange=10;
	_alpha=0;
	_yscale=0;
	_xscale=0;
}
onClipEvent(enterFrame){
	if(trip==0&&_yscale<=100){
		_alpha+=rateOfChange;
		_yscale+=rateOfChange;
		_xscale+=rateOfChange;
	}else if(trip==1&&_yscale>=0){
		_alpha-= rateOfChange;
		_yscale-= rateOfChange;
		_xscale -= rateOfChange;
	}
}

I have found that somewhere along the line you lose a little alpha during each transition. I’ve cleaned that up by adding a little code.

onClipEvent(load){
	trip=1;
	rateOfChange=10;
	_alpha=0;
	_yscale=0;
	_xscale=0;
}
onClipEvent(enterFrame){
	if(trip==0&&_yscale<=100){
		_alpha+=rateOfChange;
		_yscale+=rateOfChange;
		_xscale+=rateOfChange;
		if(_alpha==100||_yscale==100||_xscale==100){
		_alpha=100;
		_yscale=100;
		_xscale=100;
		}
	}else if(trip==1&&_yscale>=0){
		_alpha-= rateOfChange;
		_yscale-= rateOfChange;
		_xscale -= rateOfChange;
		if(_alpha==0||_yscale==0||_xscale==0){
		_alpha=0;
		_yscale=0;
		_xscale=0;
		}
	}
}

Thanks for the code David!
Thanks for explaining it also, because now I understand why it works :slight_smile:
I havn’t been doing Actionscript for long, where is a good place to learn?

is there any easier way to do it in flash 5 (or MX)?

I only have a couple of rollover effects so I have no problems, but if I had more complicated ones it may be difficult to write script for each of them… just wondering.

I think last time ilymasse(sp) said something like onClipEvent(enterframe) {previous frame} ?