A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Eye and Mouse experiment

  1. #1
    the cheesy child bounceboy's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    323

    Eye and Mouse experiment

    I am making one of those things where there's an eye and it is looking at where ever the mouse is.

    the making the code isn't a problem...

    here it is:

    onEnterFrame = function(){
    a1 = eye._y-_ymouse;
    b1 = eye._x-_xmouse;
    angleA1 = Math.atan2(a1, b1);
    degrees = angleA1/(Math.PI/180);
    setProperty ("eye", _rotation, degrees);
    }

    i have attempted heaps of times to make it so that instead of having instance names, i can put the code in the movieclip and i won't have to use any instance names.

    the reason i want to do this is i will make a whole crowd follow the mouse with their eyes, possibly for the background of a game or even a big part of the game.

    anyway if somebody could help me i would really appreciate it and stuff!!!


    thank you to anybody who helps!!!


    EDIT: wow i have already solved this problem.... look at my code and feel free to use it!

    onClipEvent (enterFrame) {
    a1 = this._y-_root._ymouse;
    b1 = this._x-_root._xmouse;
    angleA1 = Math.atan2(a1, b1);
    degrees = angleA1/(Math.PI/180);
    this._rotation = degrees;
    }

    you have to make an eye that is a normal circle and the eye has to be originally facing left in the movieclip.
    Last edited by bounceboy; 03-28-2009 at 04:15 PM.

  2. #2
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    that would be a funny idea for a tennis game where everyone's eyes follow the ball lol. For the record, you could have put code like this in the timeline if the eye movieclip to:

    PHP Code:
    this.onEnterFrame = function(){
        
    a1 this._y-_root._ymouse;
        
    b1 this._x-_root._xmouse;
        
    angleA1 Math.atan2(a1b1);
        
    degrees angleA1/(Math.PI/180);
        
    this._rotation degrees;

    Evolve Designs Interactive Media
    the natural selection

  3. #3
    the cheesy child bounceboy's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    323
    lol the whole movie rotating!

  4. #4
    Senior Member Shnitzel's Avatar
    Join Date
    May 2007
    Location
    IL
    Posts
    130
    Place it inside the eye MC,
    or change "this" to the eye instance name.

  5. #5
    the cheesy child bounceboy's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    323
    oh i thought he was saying that "for the record"

    anyway I already know guys, look at the EDIT.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center