A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: loaded swf in container swf drop and drag not working

  1. #1
    Member
    Join Date
    Dec 2004
    Posts
    68

    loaded swf in container swf drop and drag not working

    I have a jig saw puzzle that works fine on its own, but once loaded into a container swf, the drop and drag becomes sporadic. The pieces will not drag, then they will drag but not drop, then they drop but won't drag again. After a few clicks, the drag won't work at all. All the buttons in the loaded swf work fine, just the drop and drag doesn't work.

    The puzzle swf is loaded using the Loader. Any ideas would be appreciated.

    Please let me know if more information is needed.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Can you post some code for the drag and drop only.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Member
    Join Date
    Dec 2004
    Posts
    68
    Here is the code for the drop and drag:

    Code:
    function dragPcs(e:MouseEvent):void
    {
    	for (var i=0; i<PcsArray.length; i++)
    	{
    		if (PcsArray[i].hitTestPoint(mouseX,mouseY,true))
    		{
    			PcsArray[i].startDrag(true);
    			setChildIndex(PcsArray[i], numChildren - 1);
    		}
    	}
    }
    
    function dropPcs(e:MouseEvent):void
    {
    	for (var ii= 0; ii < PcsArray.length; ii++)
    	{
    		if (PcsArray[ii].hitBox.hitTestObject(targetPcsArray[ii].hitBox))
    		{
    			PcsArray[ii].stopDrag();
    			PcsArray[ii].x = targetPcsArray[ii].x;
    			PcsArray[ii].y = targetPcsArray[ii].y;
    			PcsArray[ii].removeEventListener(MouseEvent.MOUSE_DOWN, dragPcs);
    			PcsArray[ii].removeEventListener(MouseEvent.MOUSE_UP, dropPcs);
    			correctPcsArray[ii] = 0;
    			//trace(correctPcsArray);
    			allPcsAreCorrect();
    		}
    		else
    		{
    			PcsArray[ii].stopDrag();
    		}
    	}
    }

    Any help would be apprieciated.

  4. #4
    Member
    Join Date
    Dec 2004
    Posts
    68
    Any body? Bueller? Bueller?

  5. #5
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Nothing jumps out that would cause that. But things always get wonky when dealing with children swfs.

    What does allPcsAreCorrect() do?

    Also, what does your event listener assignment look like when you set up the board. Is there anything in the parent movie that would intercept events happening in the child?

  6. #6
    Member
    Join Date
    Dec 2004
    Posts
    68
    allPcsAreCorrect() checks an array to see if all the pcs have been placed.

    The only other objects in the container are a backdrop that is behind the loader and a drop down menu to the side that does not overlap the loader.

    All other listeners deal with the menu.

    There are four frames in the container. The menu takes you to a frame and unloads the loader and then loads a new swf in to it. Every other swf that loads works fine, it is the drop and drag that acts up.

    I am using the same loader for each of the four swfs. Should I add and remove the loader (or have different loaders) for each frame and swf? Should I try having only one frame and add and remove the the backdrops from the library?

  7. #7
    Member
    Join Date
    Dec 2004
    Posts
    68
    Well, fixed it. The jigsaw game was loaded with the x and y positions at 220 and 200 (approx). Once I changed the loader to have the x and y at '0', the game worked perfectly.

    I will have to have the drop down menu on the right hand side, but everything is now hunky dorry.

    Go figure.

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