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
15 Ways to Accelerate Your Journey to $1,000,000
You know, Alexa, accelerating isn’t just about putting your foot on the gas and pushing full steam ahead. In fact, that’s the last step. Before you can accelerate, you have to optimize your machine to run smoothly and efficiently and remove as many obstac…
You're a Time Billionaire (Turn TIME into MONEY)
Hey there, Aluxer. In this session, we’re going to be exploring with you the relationship you have with time. By now, you already know that life is a strategy game. It’s all about the management of resources. How well you do in life boils down to how good…
I’m Averse To People! (A Stoic perspective)
The dynamics of desire and aversion lie at the basis of Stoic thought in regards to how we relate to the world. Aversion means a strong dislike and disinclination towards something or someone. Even though this might seem harmless, it can cause a lot of tr…
The Deadliest Thing in the Universe
13.8 billion years; that’s how long the universe has existed. Older than the planets, stars, as old as time itself. The universe is measurably vast. To put it into perspective, if we reduce that time scale down to a single year, the entirety of recorded h…
Stoic Solutions For Jealousy
When we have something we cherish, like a spouse or a friend or a certain status within a group, but we feel threatened of losing it, we experience resentment, which we call jealousy. So how can we deal with this? This video presents you stoic solutions f…
Frogfish or Seaweed...Who's to Say! | National Geographic
As a passing fish, you’d be forgiven for confusing this frog fish with a mound of seaweed. But it would be the last mistake you probably ever make. As it turns out, the frog fish is a terrifying ambush predator. The spines on this fish act as a sort of ha…