Actionscript 3 simple jigsaw puzzle question
Hello, I am attempting to modify a tutorial on jigsaw puzzles to my own needs. I am very new to AS3
What I am trying to do is very simple (I believe), I have a 6 piece jigsaw puzzle and after every piece is placed in the correct spot I would like it to lock it down and play a wav file.
the code I am using for each piece is:
_________________________________________
stop();
import flash.events.Event;
import flash.events.MouseEvent;
stage.addEventListener(Event.ENTER_FRAME,EntFrame);
function EntFrame(e:Event):void
{
//piece1
Piece1_mc.addEventListener(MouseEvent.MOUSE_DOWN, DragP1);
function DragP1(event:MouseEvent):void
{
Piece1_mc.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, DropP1);
function DropP1(event:MouseEvent):void
{
Piece1_mc.stopDrag();
}
if (Targ1_mc.hitTestObject(Piece1_mc.Tar1_mc))
{
Piece1_mc.x = 260.90;
Piece1_mc.y = 432.80;
gotoAndPlay(2)
audio_mc.gotoAndPlay(2);
}
}
___________________________________________________________
The issue seems to be that the audio file continues to play over and over since the Targ1_mc is constantly registering as hitting.
Locking the pieces is also an issue, I have tried to replace the Piece1_mc on the frame 2 with a still version of the puzzle piece but then I get a #1009 error and lose all code functionality, I am guessing this is due to my needing to removeEventListener but I am not sure how to go about that.
I hope this makes sense to someone, thank you in advance.