Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Mar 2008
    Posts
    235
    Thanks
    6
    Thanked 21 Times in 20 Posts

    ActionScript 2 - Duplicating Objects.

    Hi all,

    I have the following code which is supposed to create an identically duplicate object of the movieclip (including attached actionscript) except the instance name of course.

    Code:
    on (press) {
    	n = Number(n)+1;
    	var myName = "dup" + n;
    	duplicateMovieClip("swim_btn", myName, n);
    	startDrag(myName, false);
    }
    on (release, releaseOutside) {
    	stopDrag();
    }
    When I drag the movieclip to an area, it does duplicate the clip but when I try to drag the duplicate it makes the original snap-back to the cursor then it drags the original around.

    Can anyone help me with where I am going wrong?
    Andrew Sharman
    Web designer, developer and programmer.

    If you found my post helpful, why not give thanks! :)

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Well a duplicate clip doesn't inherit the actionscript of its parent.

    "Variables in the parent movie clip are not copied into the duplicate movie clip." from the documentation. You'll need to have functions ready to handle the new movieClip, and they won't be the on (release) type. They will need to be onClipEvent.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •