Solved

MC follows mouse question

Posted on 2006-11-27
3
231 Views
Last Modified: 2010-04-03
Hi, Experts

I would like to make the MC follow the mouse. However, it is not really working.... The 1st layer MC instance name is "allMC" and there is another movie clip inside "allMC" called "fighter".... I want to control the "fighter" inside the "allMC". Thanks

--------------------  CODE  ---------------------

allMC.fighter._x = allMC.Stage.width/2;
allMC.fighter._y = allMC.Stage.height/2;
var myConstant = 5;
_root.onEnterFrame = function() {
      var destinationX = _root._xmouse/6;
      var destinationY = _root._ymouse/6;
      inertiaX = (destinationX-allMC.fighter._x)/myConstant;
      inertiaY = (destinationY-allMC.fighter._y)/myConstant;
      allMC.fighter._x += inertiaX;
      allMC.fighter._y += inertiaY;
      //fighter._xscale += inertiaX;
      //fighter._yscale += inertiaY;
      if (_xmouse<5 || _xmouse>295 || _ymouse<5 || _ymouse>245) {
            allMC.fighter._x = allMC.Stage.width/2;
            allMC.fighter._y = allMC.Stage.height/2;
      }
};
----------------------------------------------------------------
0
Comment
Question by:mingchih
  • 2
3 Comments
 
LVL 13

Expert Comment

by:FLAASHER
ID: 18022444
its work with me ..... its move the same direction as mouse

what kind of moving u want exactly ???



FLAASHER
0
 

Author Comment

by:mingchih
ID: 18022487
Hi, Flaasher

Thanks for the reply....here is the fla file and please take a look

http://www.4shared.com/file/6551562/d63677fa/dropBomGame2.html

Thanks
0
 
LVL 13

Accepted Solution

by:
FLAASHER earned 500 total points
ID: 18022765
allMC._x = Stage.width/2;
allMC._y = Stage.height/2;
var myConstant = 5;
_root.onEnterFrame = function() {
      var destinationX = _root._xmouse/1;
      var destinationY = _root._ymouse/1;
      inertiaX = (destinationX-allMC._x)/myConstant;
      inertiaY = (destinationY-allMC._y)/myConstant;
      allMC._x += inertiaX;
      allMC._y += inertiaY;
      //fighter._xscale += inertiaX;
      //fighter._yscale += inertiaY;
      if (_xmouse<5 || _xmouse>295 || _ymouse<5 || _ymouse>245) {
            allMC._x = Stage.width/2;
            allMC._y = Stage.height/2;
      }
};
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now