Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 4 of 4
  1. Default Follow mouse - confined to a motion guide

    Hi

    I'm wanting to have an object follow my mouse position, but to have the motion fixed to a circle path.

    Please visit

    http://www.bibcredit.com

    The big circle will be the navigation, the 4 areas will light up as the mouse rolls over them.

    I would like the smaller circle on the outer edge of the big circle to follow the mouse, but need it to stay in the path of the circle, not to move round the page.

    Can't seem to find anywhere that tells me how to integrate follow mouse with a motion guide.

    thanks

    paul
    It's All Good.

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    I am not sure how to do it with a motion guide but I can achieve this effect with Actionscript. Math.sin and Math.cos are perfect for circular rotation. Math.atan can be used to determine the angle position from the mouse. However, if you dont have a good understanding of actionscript, this might seem a little confusing. Paste this code sample onto the first frame of a new movie and test......no movieclips are necessary. This effect is created dynamically with Actionscript....

    Code:
    var s = _root.createEmptyMovieClip("circle", 10);
    s._x = 250;
    s._y = 200;
    s.maxAngle = 3.6;
    s.minAngle = -3.6;
    s.r = 150;
    s.lineStyle(3, 0x8888FF);
    s.moveTo(Math.cos(s.minAngle)*s.r, Math.sin(s.minAngle)*s.r);
    for &#40;var i = s.minAngle; i<=s.maxAngle; i += .05&#41; &#123;
    	s.lineTo&#40;Math.cos&#40;i&#41;*s.r, Math.sin&#40;i&#41;*s.r&#41;;
    &#125;
    var d = s.createEmptyMovieClip&#40;"dot", 10&#41;;
    d.lineStyle&#40;15, 0x8800&#41;;
    d.moveTo&#40;0, 0&#41;;
    d.lineTo&#40;1, 0&#41;;
    d._x = Math.cos&#40;s._x&#41;;
    d._y = -s.r;
    d.onEnterFrame = function&#40;&#41; &#123;
    	var s = this._parent;
    	this.onEnterFrame = function&#40;&#41; &#123;
    		this.angle = Math.atan2&#40;s._ymouse, s._xmouse&#41;;
    		this.angle = Math.max&#40;Math.min&#40;this.angle, s.maxAngle&#41;, s.minAngle&#41;;
    		this._x = s.r*Math.cos&#40;this.angle&#41;;
    		this._y = s.r*Math.sin&#40;this.angle&#41;;
    	&#125;
    &#125;
    hope it helps
    NTD
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

  4. Default

    Hi there

    Thanks a lot for that, tried the code and it works exactly as I'd hoped.

    I'm stumped about how to put that into my design, constricting the circle to my dimensions and specifying colour, weight etc. Also the small circle being my design aswell.

    I'm not an actionscripter, have my head round basic/intermediate, but advanced stuff is way beyond me!

    Any more ideas would be well appreciated.

    thanks a lot
    It's All Good.

  5. #4
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    You can change the position of the circle in the variables...

    s._x=250;
    s._y=200;

    You can change the size of the circle in the variable....

    s.r=200; //this is the radius of the circle

    You can change the circle color in the variable...

    *The first parameter is line weight, the second is color...
    s.lineStyle(3, 0x8888FF);

    You can change the dot color in the variable...

    d.lineStyle(15, 0x8800);

    Play around with changing the above variables to see how it the code reacts. If the above wont work for you, I can do the same thing with actual movieclips on the stage that you can physically alter on the stage, I just did it dynamically to see if I could

    Regards
    NTD
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Problem with Object-Follow-Mouse script
    By Seraphine in forum Flash Scripting
    Replies: 6
    Last Post: 07-13-2010, 11:29 AM
  2. Masking motion guide
    By spencerman in forum Newbies
    Replies: 1
    Last Post: 11-05-2005, 01:19 PM
  3. Hiding a mouse creating a new mouse and make that reveal?
    By orkdaorc in forum Flash Scripting
    Replies: 13
    Last Post: 10-17-2004, 08:25 AM
  4. mask and guide layers together/ HELP!
    By tamara19 in forum General Flash
    Replies: 1
    Last Post: 08-16-2004, 04:33 AM
  5. maskin and moving on guide. help please!!
    By tamara19 in forum Design and Animation
    Replies: 2
    Last Post: 08-10-2004, 11:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial