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
AP Microeconomics FRQ on perfect competition | AP(R) Microeconomics | Khan Academy
Is a type of question that you might see on an AP economics exam, and it’s talking about perfectly competitive markets. So it says a typical profit maximizing firm in a perfectly competitive constant cost industry is earning a positive economic profit. S…
The Controversial Physics of Curling - COLD HARD SCIENCE - Smarter Every Day 111
Hey, it’s me Destin, welcome back to Smarter Every Day. So in the last episode, I explained that it’s not always the most athletic team that wins in sport; sometimes it involves the physical manipulation of objects, so sometimes it’s the most intelligent …
Alfred Lin with Justin Kan
Next up, I’m pleased to introduce Alfred Lynn, who’s a partner at Sequoia Capital, one of the top investors in Silicon Valley and the world. He serves as a director on a bunch of awesome Silicon Valley companies like Airbnb and Houzz. Before that, he was …
Edgar: crowdfunding drive
Uh, my name is Thomas, and last year I made the film “George Ought to Help.” Right now, I’m working on a follow-up called “Edgar the Exploiter.” It will be similar to George in that it will be a gentle pro-liberty propaganda piece, because George was a s…
Let's Talk About Clean Energy | Breakthrough
I believe that there is energy, clean safe energy all around us, and that it is our opportunity now and our obligation to find ways to access it. I’ve always had great fun converting other people’s work into my own. When I was a kid, I liked coloring book…
The On, Off Switch of Consciousness | Breakthrough
To map what goes on inside the brain, Muhammad implants tiny electrodes in his patients’ skulls. He then sends pulses to these electrodes, gradually increasing the current, sometimes with dramatic results. Recently, he inserted an electrode next to a smal…