Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to allow the user to DRAG an object in your movie

Step-by-step tutorial

How to allow the user to DRAG an object in your movie

by  davdesign  Posted    (Edited  )
[color green]Just to let you know that I'm relocating my server as of today, and for a period of three to four weeks, none of the links to my files on this site will work.

If you need a file from me which is linked from this site then please just email me details of the relevant link and I will send the relevant file(s) to you.

After I've relocated the server and all the files within it I shall endeavour to update all links in Tek-Tips.[/color]




Had a few requests for this by e-mail in the past few days.

Question:[color red]
I need the users of my site to be able to click and drag an object to a new position on the screen.[/color]

Answer:[color red]
Very easy and quick to create.

1>>>[/color]
Create the graphic/movie-clip you want the user to be able to drag (if it's just a graphic, convert it to a movie-clip by right clicking the name of the graphic in the Library and change the 'Behaviour' to Movie-clip). Drag a copy of the graphic onto the main stage and give it an instance name (Ctrl+i), say "object".

[color red]2>>>[/color]
Press Ctrl+F8 to create a Button symbol. Now within this button in the HIT frame, insert a copy of the graphic you used in your movie-clip.

[color red]3>>>[/color]
Double-click your movie-clip in the Library. If your movie-clip contains a graphic 'symbol' (ie: the graphic exists as it's own entity in the Library) then double-click that now. Drag a copy of your new button from the Library to the stage and align (Ctrl+k) the button (should appear as green-ish) and the graphic so that they lie on top of each other. Stay here.

[color red]4>>>[/color]
Right-click the button and select 'actions'. Insert the following actions:

[color green]on (press) {
startDrag ("_root.object");
}
on (release) {
stopDrag ();
}
[/color]

[color red]5>>>[/color]
Press Ctrl+Enter to test. This effect does not require additional frames (ie: can be contained within a single frame)

For an example:
www.pinkzeppelin.com/FAQ/250-600/drag-movie.html
www.pinkzeppelin.com/FAQ/250-600/drag-movie.fla

For a previous tutorial on the same theme:
www.pinkzeppelin.com/FAQ/250-600/dragtext.html
www.pinkzeppelin.com/FAQ/250-600/dragtext.fla

Good luck with your projects.
dave
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top