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
WE DID IT! Thank you all and Merry Christmas!
[Music] We did it, guys! We did it! Come on, that’s so awesome! Guys, 25 YouTube videos in 25 days! The new money advent calendar is successfully completed. Well done, everyone! Well done for keeping up to speed. There’s been about, you know, three to fo…
Solar eclipses | The Earth-sun-moon system | Middle school Earth and space science | Khan Academy
Have you ever been minding your own business, enjoying the sun, when someone steps in front of you and blocks your sunlight? This is pretty much what happens during a solar eclipse, except on a planetary scale. As Earth revolves around the sun, the moon r…
A productive day in my life vlog
Hi guys, it’s me, Dude! Today, we’ll look at a day of a productivity ninja. I woke up at 5:30 AM using my Yabai sunlight alarm. I represented my waking up scene to show you guys how I feel when I wake up super early. We had many things to do this day, so…
This Spider Wears Its Victims Like a Hat | National Geographic
This massive ant colony maintains cohesion through constant chemical communication. This signaling method facilitates the collection of food, defense of the colony, and, very creepily, collection of their dead. However, chemical signatures can be minute. …
Functions | Intro to CS - Python | Khan Academy
You’re writing a program, and it’s starting to get pretty long. Plus, you’re duplicating a lot of code because you need to perform the same task at several different points in the program. How can we better keep this code organized and reduce the repetiti…
North Carolina's Nuclear Incident | The Strange Truth
[Music] Bomb number one was literally a Washington Monument right in the middle of a tobacco field, tail up in the air. The parachute that had deployed was strewn amongst the branches. We found that the weapon was in sufficiently safe condition to transpo…