dcsimg
A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Delay a drag effect. How?

  1. #1
    Junior Member
    Join Date
    Dec 2000
    Posts
    8
    I've seen many Flash movies that have an element that is floating around the stage but when the user mouses over the element is dragged but in a kind of delayed and lazy way. Any ideas how this is done? Is it some kind of math action added to the startDrag command?

    Take a look at this to see what I mean.

    http://www.digit1.com/party/

  2. #2
    Senior Member
    Join Date
    May 2001
    Posts
    170
    it is not a kind of "startDrag" + some maths, this is a "check mouse position and calculate object position from if"

    basic idea is (it is not correct code, idea only):

    let say you can use detection of mouse position

    onClipEvent (mouseMove) {
    _root.checkedY = _root._ymouse
    }


    and on clip you need to move make a loop

    if (this._y < _root.checkedY) {
    this._y += 5
    } else {
    this.stop()
    }


    Alex

  3. #3
    Member
    Join Date
    Aug 2000
    Posts
    59
    Metamind is right.
    Here´s how it works:
    1) First you must create a MC wich must be not visible.
    2) You must drag ONLY that MC.
    3) Create a second MC.
    4) Now, with that second MC you must "follow" the first one but adding some friction.

    If you want it I can send you an example.

    Hope it could be usefull!

    Greetings,
    Strato

  4. #4
    "way too many questions"
    Join Date
    Feb 2001
    Posts
    312
    Reading this posts it came to my attention I don't get thsi stuff too

    strato if you could be so nice to send me the fla too!
    ja.rotteveel@chello.nl


    Thanx!

  5. #5
    Junior Member
    Join Date
    Dec 2000
    Posts
    8
    Originally posted by strato
    Metamind is right.
    Here´s how it works:
    1) First you must create a MC wich must be not visible.
    2) You must drag ONLY that MC.
    3) Create a second MC.
    4) Now, with that second MC you must "follow" the first one but adding some friction.

    If you want it I can send you an example.

    Hope it could be usefull!

    Greetings,
    Strato

    Strato/Metamind
    Many thanks on this. Strato, I would be much obliged if you could send me the example. My address: jpeer@supanet.com

    Thanks again

    James

  6. #6
    Senior Member
    Join Date
    May 2001
    Posts
    170
    I will send you .fla

    you do not need two MCs, all is done on one MC, I made all codes effective (no enterFrame hadlers, all code stops when no mouse move etc.)


    Alex

  7. #7
    Junior Member
    Join Date
    Mar 2001
    Posts
    12

    I would really appreciate it.....

    If it would not be too much trouble could you pls send me the fla too. Im struggling with the same problem and my coding is not the best. Thanks.

  8. #8
    Senior Member
    Join Date
    May 2001
    Posts
    170
    be patient for a moment, I had a lot of work, but just now I am free

    I will post a link to download it, is it OK for all?


    Alex

  9. #9
    Junior Member
    Join Date
    Mar 2001
    Posts
    12

    Smile that would be great

    Yes thanks. Im sure it will be fine.

  10. #10
    Junior Member
    Join Date
    Dec 2000
    Posts
    8
    Alex
    Thats good for me. Thanks mate

    James

  11. #11
    "way too many questions"
    Join Date
    Feb 2001
    Posts
    312
    G RE AT !!!

  12. #12
    Senior Member
    Join Date
    Apr 2001
    Posts
    168

    ok

    I made something like it... sorry about the idea... not my idea, just asked to make it!:

    http://www.rdesign.250x.com/follow.swf

    will be up in 10 mins

  13. #13
    Senior Member
    Join Date
    May 2001
    Posts
    170

    here it is

    http://www.botticelli.cz/files/frictedMoving.fla


    using input text fields you can combine linear and non-linear movement of MC, which follows mouse Ypos

    coef need to be less than 1

    for example, to experiment with non-linear movement, set linear movement startStep value to zero, and just now you can set these values:

    coef = 0,99999999
    divisor = 0,00000007

    or

    coef = 0,1
    divisor = 50


    when you will check script inside of MC, key is changig step value.

    for linear movement step grows _y pos of MC "steadily". for non-linear it counts a value from difference between mouse _y pos and MC _y pos.


    you can combine linear and non-linear


    hope this helps a little bit


    Alex

  14. #14
    Junior Member
    Join Date
    Mar 2001
    Posts
    12

    Great Idea

    I think that is a brilliant idea. Well done.

  15. #15
    "way too many questions"
    Join Date
    Feb 2001
    Posts
    312
    Thanks alex i received it in my mailbox!!!!!!


    Great work you're doing here at FK

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