?
Solved

MC follows mouse question

Posted on 2006-11-27
3
Medium Priority
?
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

801 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