yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Object Follows mouse in Flash


2m read
·Nov 3, 2024

Hey guys, this is Mads 101. Today I got another special guest showing you how to do something special in Flash. So, uh, here we go.

Hey guys, so in, uh, for today's tutorial, I'm going to, uh, make an object follow the mouse with, uh, Flash ActionScript. I'm using Flash ActionScript 2.0.

So I'll start off by drawing a little object, then I'll convert that to a movie clip. I'll name it "Smiley Face." Now I'll open up the actions, which, uh, which will be how you actually make it follow the mouse.

So I'll start off by writing "onClipEvent(enterFrame)," which will make it so that it, uh, every time, every, uh, or the frames per second is 12. So 12 times per second, it should, uh, it should do that.

Within the inside the brackets, so I'll write in "x = _root._x + _dxMouse." And what this means is that it sets a variable called X, and that equals, uh, the X Mouse in the, uh, _root.

So then I'll do "y = _root._y + _dyMouse," and this does the same thing for the, um, Y component of the, uh, of the mouse.

Now I'll make it so that it, um, moves. So I'll do "x += x - _dx;" then I'll do "y += _Y - _dy."

Now, if I test the movie, it should be following the mouse. And I'll, I'll bump up the, uh, frames per second to 24 so it looks better, smoother.

And now, it's not using yet—it's only, uh, on the mouse. So I'll, I'll make it so that it eases by dividing the thing that it's, uh, the ratio there, or the, uh, little subtraction thing, and I'll divide the whole thing by 10.

I'll do that for both the X and the Y. So now, if I, if I test the movie, it should be following the mouse; it should be easing to the mouse.

And, uh, that's all. Um, and there'll be, uh, the code will be in the description of the video. And, uh, that's all.

More Articles

View All
The Jacobian Determinant
In this video, I want to talk about something called the Jacobian determinant. It’s more or less just what it sounds like: it’s the determinant of the Jacobian matrix that I’ve been talking to you the last couple of videos about. Before we jump into it, …
How I made my life a video game
(Piano music) - So I’ve talked on this channel before about how I think there are a lot of parallels between video games and real life. In a video game, as your character progresses through the game and you upgrade your stats and make more money, you’re a…
Conditions for IVT and EVT: table | Existence theorems | AP Calculus AB | Khan Academy
We’re told this table gives a few values of function f. It tells us what f of x is equal to that x is equal to 2, 3, 4, and 5. Which condition would allow you to conclude that there exists a maximum value for f over the closed interval from 2 to 4? So pa…
Why does your vote matter? | US government and civics | Khan Academy
Why does your vote matter? Your vote matters because, uh, in the most specific case, there might be a race where you live for the House or the Senate, or even the presidency, where your vote really could determine who the winner of that race is. We saw i…
International Human Rights | 1450 - Present | World History | Khan Academy
We hold these truths to be self-evident, that all men are created equal, that they are endowed by their creator with certain unalienable rights, that among these are life, liberty, and the pursuit of happiness. This is an excerpt of the US Declaration of …
The Real Estate Market is BROKEN (The End of Homeownership)
The US housing market is officially broken. Buying a house has never been as unaffordable as it is today. The rise in property values is helping cause a Great Divide that is straining the social fabric of this country. On the one side, you have property o…