Flasher Archive
[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]
Subject: | RE: FLASH: snap back |
From: | Eric Smollin |
Date: | Mon, 25 Oct 1999 19:21:14 +0100 |
>i'm trying to set up a drag-n-drop where the user
>takes a specific object and drags it to a specific target object.
>if the user drags it to that target (and releases the mouse) then
>the object sticks. if not, it should snap back.
>can i do this in flash? if so...how?
Yes, that can definitely be done. In a nutshell, here's what you do:
1.) Create the target area as a MC, insert it on the main stage, and give it
an Instance Name (something like "target" will work, no quotes).
2.) Create a MC for your dragged object. This MC will include two keyframes,
the first one will have the following actions:
Stop
Set Variable: "ClipX" = GetProperty ("", _x )
Set Variable: "ClipY" = GetProperty ("", _y)
The second keyframe will contain a stop action.
3.) Create a button (this button is the object that you want to be dragged)
and put this button in the MC mentioned above. Give it the following
actions:
On (Press)
Start Drag (GetProperty(_x, _y))
End On
On (Release)
Stop Drag
If (_droptarget eq "/Target")
Go to Next Frame
Else
Set Property ("", Y Position) = ClipY
Set Property ("", X Position) = ClipX
End If
End On
Remember that "target" is the instance name you gave to the drop area on the
main timeline, and the "/" tells Flash to look up one level to the main
timeline.
What you are saying is this; If the object is dropped on the target, go to
then next frame of the MC (which by the way contains an instance of your
button with the behavior set to graphic, and a Stop action). Else, shoot
back to the original position (_x and _y).
I hope that helps. If all it did was confuse you I can send you an example
FLA, just contact me off-list.
Good Luck
-Eric-
flasher is generously supported by...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Streaming Media WEST '99 Conference & Exhibition
"The Worlds largest Internet Audio & Video Event"
December 7 - 9, San Jose Convention Center, California
Reserve your space today at http://www.streamingmedia.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpchinwag [dot] com
[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]