I am in need of easing… and since your formula is so golden, Voetsjoeba, I’d like to ask… how do i apply it? if there a way you can create a sample .fla for me?
My goal is to movie a mask to a certain point with easing and when it has reached that destination, execute some other movieclips…
Any help would be greatly appreciated! And soon… I shall be calling you the golden child!
onClipEvent (load) {
// set some vars
speed = 10;
minDistance = this._width/2;
to_far_away = true;
}
onClipEvent (enterFrame) {
// ease the object towards the mouse if its to far away
if (to_far_away) {
this._x += (_root._xmouse-this._x)/speed;
this._y += (_root._ymouse-this._y)/speed;
}
// calculate the distance from object to mouse
ab = Math.abs(this._x-_root._xmouse);
bc = Math.abs(this._y-_root._ymouse);
distance = Math.sqrt(ab*ab+bc*bc);
// compare distance to allowed minimal distance
if (distance<=minDistance) {
to_far_away = false;
} else {
to_far_away = true;
}
}
Yup, scotty pretty much said it. It’s a MovieClip prototype, so you can just apply it like you’d apply gotoAndPlay(5): themovieclip.easeTo(52) for example. If you have one with two axis movements and thus 2 arguments, then it’d be themovieclip.easeTo(63,59) for example. Of course, these numbers are only examples.
Hmmm… I see the result, but I’m still trying to understand all of the actionscript commands… So, from what I understand Voet, is that once that statement is executed in flash, you can just use it in a simple button action:
on (release) {
mc1.easeTo(63);
}
But, I see from my own testing that this isn’t working… I’m missing something… I don’t mean to be a pain, but I really appreciate your help!
Right, well… it certainly shows that I am not a morning person… I just assumed that “easeTo” was the naming convention that was used in the fla… ha, well… now that I’ve figured out why it didn’t work for me, it makes sense… how embarrassing :trout:
…Now, two more things… 1) which part of this statement could i get rid of if I didn’t want the MC to move as soon as the .swf started playing? This?:
function nextMc() {
if (d<amount) {
d++;
this[“mc”+d].easeIn(450);
}
}
nextMc();
If i wanted to create the Y property too, would I just copy the same code and change all of the X values to “Y”?
Sorry for the delay, as you can see in my user title I’ve been very busy lately.
Yes, once the prototype code has been executed, you can use it all over your movie
Get rid of the nextMc(). That line actually executes the function which you defined above. If you don’t execute it, it won’t do no nothing, so take away the line that executes it
No, but you would add similar code to it like the code that’s already in it. Here’s the prototype for 2 axis easing:
Alright, that’s what I thought… now if I wanted to tell a movieclip to go to a certain point using the Y axis, how would I do that?
using this function:
on (release) {
mask.easeIn(500);
}
…uses the X axis only… so how would I tell the movie clip to move along the Y axis?
Thank you very much, Voet! I appreciate all of your guys help with my issues… This website is by far the best Flash tutorial site I have found… and th forums don’t hurt either Once again, thank you!
…ok… Voet… I think this will be the last request… I’ve figured out how to manipluate the X and Y with easing - your golden formula is nothing short of it’s reputation. Now! How can I add in changing the Width and Height within this formula too!? That is my final request on this subject… at least for now…
Alright everyone… through the evolution of this topic I have been helped in numerous ways… To answer my own question I have manipulated Voets Golden Formula to effect the _x, _y, _width, and _height. For all the nubs that are in my former shoes, here’s the answer (of course, there could be some tweaks):
Isn’t it better to combine the two if statements?
Cause if the difference between x/y and tarX/tarY is small, the onEnterFrame will be deleted, before you reach the chosen width/height;)
Oh, well done l2edsand ! It’s not perfect, but you definitely were going the right way ! You can pretty much ease anything that way, that’s why I called it “my golden formula” just for kicks before, and it kept that name although that wasn’t intended :lol:
Then, create a square and convert it into a movie clip… give it an instance name of whatever you want (i.e. “mc” without quotes). then… you can create a button. once the button symbol is created drag it onto the stage if it isn’t there already and click on it - open up the actions panel and paste this code into it:
on (release) {
mc.easeIn(10,50,350,40);
}
That should take your box mc and move it to the x,y corodinates of 10 and 50 and change the size of it to 350x40… just play around with it… it’s really simple after a while. And if you need to, take a glance through the code to familiarize yourself with what’s actually being done there.