| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Jun 2001
Posts: 1
|
Hi All,
I'm very new to action scripting and could really use some help! I am trying to create a jigsaw puzzle (with the classic puzzle piece shape) in Flash and I want the user to drag and drop pieces to a specific location in the puzzle. If they drop a puzzle piece into the right location I want the piece to lock into place and a sound to be played. So far I am able to do most everything except lock the piece in place. I don't want the user to be able to move a piece once he/she has placed it in the right location. Is it possible to lock it and stop the drag action for that particular piece? Thanks for any advice! Cheers, Elisha |
|
|
|
|
|
#2 |
|
Risu Oyabun!
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
|
Jesse's site has a great example of this on the Draco & Friends stuff (my son loves it). You should check it out.
Anyhoo... first get the exact coordinates for each peace, or at least a bounding box worth of coordinates. In the code for the release, you should have it check to see if the dragged MC is within the range of the target coordinates. Very simple stuff. It'll look something like this: Define within each piece the range of coordinates you want it to snap to... dest_x1, dest_x2, dest_y1, dest_y2 Code:
on (release) {
if ((pzlpc1._x >= pzlpc1.dest_x1 && pzlpc1._x <= pzlpc1.dest_x2) &&(pzlpc1._y >= pzlpc1.dest_y1 &&pzlpc1._y <= pzlpc1.dest_y2)) {
setProperty (pzlpc1, _x, 131.7); // point x to snap
setProperty (pzlpc1, _y, 296.3); // point x to snap
} else {
setProperty (pzlpc1, _x, 450); // point of x origin
setProperty (pzlpc1, _y, 250); // point of y origin
}
}
[Edited by 20 Ton Squirrel on 06-14-2001 at 01:54 PM] |
|
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Drag and Drop question? | jbking | ActionScript 1.0 (and below) | 1 | 04-30-2004 02:55 PM |
| Drag and Drop.. basic question | tonyaskinner | ActionScript 1.0 (and below) | 1 | 02-11-2004 11:22 AM |
| drag and drop question | truth789 | ActionScript 1.0 (and below) | 5 | 07-24-2003 05:19 PM |
| Drag and Drop question | teaches49 | ActionScript 1.0 (and below) | 2 | 01-15-2003 01:47 PM |
| A Drag and Drop Question | S3kS | ActionScript 1.0 (and below) | 3 | 04-24-2001 12:59 PM |