A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Animation Question

  1. #1

    Animation Question

    I'd like to know if there is a way to call up a frame in a flash movie by the angle of the mouse as it is possitioned from a centeral x/y possition. This is way over my head as far as coding goes, but i think i could reduce my file size and perhaps have my animation follow my mouse even when the user isn't pointing to something over the movie if I can figure out how to do this with actionscript instead of buttons.

    Thanx

  2. #2
    Senior Member Ingale's Avatar
    Join Date
    Jun 2003
    Posts
    332
    If you want an animation to follow the mouse - create a MC, within it create an animation, make sure it centered, get back to the main stage, drag the MC you've just created into the main stage, right click on the MC, select Action and paste this script:

    code:

    onClipEvent (load) {
    startDrag("", true);
    }


    Sometimes the most simple things are the most effective...

  3. #3
    Senior Member FPChris's Avatar
    Join Date
    May 2003
    Location
    NJ
    Posts
    644
    Trying to follow you. Do you need the angle say from stage center,
    Point A, to the current mouse location, Point B?

    If so, see the attached for calculating a line's angle.

    Chris
    Attached Files Attached Files
    http://www.**********-dms.com

  4. #4
    well the idea is, that I have a drawing of a girl and i have illustrated her head turning to look around 360 from the center of her face. I have one angle on each frame. And the effect is to have her looking where ever the mouse is pointing.

    Right now i'm using buttons to call each frame on roll over, but i was hoping for a code that might do it based on angle/degree from the x/y of the center of her face.
    Last edited by RazzberryGirl; 09-06-2003 at 06:54 PM.

  5. #5
    I haven't tested this but it should be similar to what you want

    put it into an onEnterFrame function

    code:

    /*************
    vars -
    cx = center of girl's head (x-position)
    cy = center of girl's head (y-position)
    dx = change in x from girl's head to mouse
    dy = change in y from girl's head to mouse
    rads = angle from positive x-axis to line from girl's head in radians
    degs = same as rads but in degrees
    frame = frame number to go to
    *************/

    dx = _root._xmouse - cx;
    dy = _root._ymouse - cy;

    // get angle
    rads = Math.atan2(dy, dx);
    // convert to degrees
    degs = 180 / Math.PI * rads

    // convert to 0-360 just in case
    frame = Math.floor(degs) % 360;



    I think that might work

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I don't know exactly if this is what you want but it may come close.
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    I put the code yasunobu13 gave on the first frame and was able to understand it as far as the cx and cy. I extended my frames out to take up 360 frames so that there's something there for all 360 degrees when called upon by the angle of the mouse's possition in relation to the x/y center. What confuses me is the rest of the code. What does "change in x from girl's head to mouse" mean? And do I have to figure out any stuff for the rads, degs and frame? if so can you point me in the right direction? Cause I know something's wrong since it didn't work :\

    /*************
    vars -
    cx = center of girl's head (x-position)
    cy = center of girl's head (y-position)
    dx = change in x from girl's head to mouse
    dy = change in y from girl's head to mouse
    rads = angle from positive x-axis to line from girl's head in radians
    degs = same as rads but in degrees
    frame = frame number to go to
    *************/

  8. #8
    bump

  9. #9
    bump

  10. #10
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    RazzberryGirl (pretty name ),

    why don't you try the Math forum. This is more of a Math question. Hope that may help you.
    - The right of the People to create Flash movies shall not be infringed. -

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