Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MC follows mouse question

Posted on 2006-11-27
3
Medium Priority
?
240 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:Brian Lin
[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:Brian Lin
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
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…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to record live broadcast.

618 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