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
Welcome to Financial Literacy! | Financial Literacy | Khan Academy
Hi everyone! Sal Cotton here from Khan Academy, and I just wanted to introduce you and welcome you to our financial literacy course. Why financial literacy? Well, money is everywhere, and if you don’t understand money, it can easily take control of your …
Ways to rewrite a percentage
[Instructor] We’re asked which of the following options have the same value as 2% of 90? Pause this video, and see if you can figure it out. And as a reminder, they say, pick two answers. All right, now let’s work through this together. So, before I eve…
Interviewing a Former White Nationalist | Trafficked with Mariana van Zeller
You’ll never get the truth from a current extremist. Their whole job is to lie to you and to spin things their own way. Which is why I say if you want the truth, talk to a former extremist. You still have the jacket? Still have the jacket? Oh, so this wa…
Watching a Rocket Launch at SpaceX with Elon Musk!
That I’ve never seen something like that, and the noise of it when it was going up was insane. I asked Grandpa, “What do you go in it?” and he goes, “What up, guys? Welcome back to the channel! Today, we are on Trump Force One, going to see the Starship r…
Credit 101: What is APR and why does it matter? | Loans and debt | Financial Literacy | Khan Academy
Let’s talk a little bit about credit, in particular how much you pay for credit. So just as a reminder, credit is essentially the ability, or when you actually borrow from someone else. It could take the form of a mortgage, where you say you’re borrowing…
Inside NELK’s $250,000,000 Empire (The Full Story)
All right, I want to know something: who right now is doing it like Milk? Nobody! There’s nothing like us on the internet right now. Kyle’s talked about it being worth a quarter million recently on a podcast. Um, I think Happy Dad alone this year will be …