A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: praystation.com --> Trowing MC's with some speed and then slow them down?

  1. #1
    Junior Member
    Join Date
    Feb 2000
    Posts
    20

    Question

    Hi flashers,

    I've got a question for you.
    I visited praystation.com and was asking my self how a special effect was made. I'm calling about the movie of 25th januari.

    It show a calendar in 3 layers and you can drag each layer so you can see other days. But what I really like is the way it works: you can pick up a layer (movieclip) and trow it away with some speed. When releasing the mouse, the movement slows down till the mc stands still. So it keeps moving a while (a second or something like that) even when I'm not dragging anymore! And the way this happends depend on how fast I trow it away.

    How is that done? I can you find out at what speed someone is dragging? Do you need a contunious status checker that builds some sort of array with positions and then counts the dragging speed? Than I know how to slow down?

    I've got some thoughts about it, but I'm not sure that I'm right!

    What do you think?

    Waldo

  2. #2
    Hack
    Join Date
    Mar 2000
    Location
    Madison, WI
    Posts
    1,753

    Lightbulb

    Waldo,

    I've never done this personally, but I think how I would approach it is as follows:

    I would assume that you gauge the speed of dragging by recording the time and the distance of the drag. Remember algebra? Rate = Distance/Time. So you'd do an OnPress GetTimer, and an OnRelease GetTimer, and subtract the former from the latter, to give you your drag time.

    Then you record the x and y values at the start and end of the drag. That gives you your distance, as well as your vector which the dropped object has to follow as it slows down.

    Actually calculating the rate of slowdown, well, that's up to you. Also, one problem with this process is, if you hold the dragging item in one place for a long time, and then fling it hard, it still will think it's been dragged slowly.

    That's my two cents.

    erlenmeyer

  3. #3
    Junior Member
    Join Date
    Feb 2000
    Posts
    20

    Post

    Erlen,

    thank you. I already thought about this and I think it will be the best way.

    But while I'm typing this i think about a new option: Perhaps i need a movieclip that checks the position of the movieclips that can be dragged and dropped. It will do the same thing as your actionscript, but only starts to work when "current position <> previous position", do you know what I mean?

    This avoids the OnPress problem.

    Hmmm... i think I'm going to try this.

    Waldo

  4. #4
    cre8ive
    Guest

    Post

    There is another option. When releasing the object being thrown you measure the its velocity when released by taking the difference between the objects current position and its previous position. This difference will be considered vector velocity of that object when the mouse press is released. This vector must be broken into its x and y components. This can be done by taking the difference between the x_property_of_object_current - x_property_of object_previous = x_component_vector. The same needs to be done for the y component. Now you can make the object move at a rate reletive to the speed in which the object was tossed by adding the x or y component vector to the the objects current x and y possitions, then setting the x and y properties to the new values in a loop. This will make the object fly at a constant rate. In order to make the object slow down you must add a factor of decay. An easy exponential factor of decay can be done by subtracting the xcomponent divided by a factor (any number the larger the number the longer it takes for the object to slow down) from xcomponent. setvariable ("xcomponent")=xcomponent -xcomponent/factor Make sure the vector components are scaled before the object properties are reset by placing the setvariable command above the set property command.


    cre8ive www.especio.com

  5. #5
    Junior Member
    Join Date
    Feb 2000
    Posts
    20

    Post

    Thanks man!

    I've got enough info to start playing with it right now.... it's almost can't be difficult with all your help.
    You'll hear when I've succeeded in it.

    Waldo

    ------------------
    ------------------------------------
    See you soon at www.WaldoSmeets.com

    Visit the company I work for at www.care.nl

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