A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: Drag and drop after duplicate

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    21

    Drag and drop after duplicate

    Hi guys, I'm having trouble working this one out. I am trying to make multiple ducplicates of an mc on a button press. The duplicated mc's also have a drag and drop applied to them.

    I have the following AS which will amke my duplicates. The only problem is when I get to my third duplicate, all future mc's are not draggable. Only the 3rd mc is.

    code:
    on (press) {
    typea202.duplicateMovieClip("typea202"+i, this.getNextHighestDepth(), {_x:20, _y:20});
    i++;
    amount--;
    }



    Could any one please help?

    Cheers
    Rich

  2. #2
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    Well, i just copy 'n pasted that code into a new flash project with a button and a draggable mc called typea202 and it worked fine. Which probably means that the problem is in some stupid accidental thing which which you didn't realise was there.

    So unless you've fixed it i suggest uploading the source.

    also, what is the point in the amount variable

  3. #3
    Junior Member
    Join Date
    Mar 2001
    Posts
    21
    Hi,

    I have uploaded an fla for you it is in 8. If you drag each window once you have duplicated it you should see my problem.

    I have to admit it is taking me some time to get my head around AS and I think the amount variable was just a mistake left over from another attempt whilst trying to learn how to do this.

    Cheers
    Attached Files Attached Files

  4. #4
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    Ok, the problem is that you're referencing a variable 'i' which doesnt exist. What you need to do is change it to _root.i++ and in _root write i=1;

  5. #5
    Junior Member
    Join Date
    Mar 2001
    Posts
    21
    Dr Doom - I think not!! More like Dr Happiness.

    Thanks mate - that's sorted the little blighter.

    Just another quick question though - I've applied this successfully working off of the main timeline _root. I am now trying to apply this between two scroll panes. the button in one and the window in the other.

    I this case I have used the same logic but applied the relevant path for the name of the window mc (_level0.elevations.tmp_mc.typea202) - elevation being the instance name of the scroll pane).

    I have applied i=1 on frame one of the mc that holds the window mc, in an attempt to replicate it bieing in the root.

    This works for the duplicate, but I am back down to only getting one duplicate instead of many as before??

    Any ideas as to what I am doing worng? Should I use attach moive clip intead?
    Last edited by Meadsy; 04-22-2006 at 01:50 PM.

  6. #6
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    Probably still means that its not referencing variable i correctly.

    The reason it does 3 is because the first one(typea202) is allready there. Then when it tries to make a new one with _root.i it creates one called typea202undefined. Next is attempts to increase _root.i by one which returns NaN as it was initially undefined so the next one it creates is called typea202NaN. It works fine up to this point, but when you create the forth one, _root.i is NaN again as NaN+1 returns NaN. This means that there are now 2 typea202NaNs so it stops working

    back to your question - if you have moved i to somewhere you need to change all of the _root.is to _root.MC.i or whatever. This includes the one in the line which starts typea202.duplicateMovieClip. In fact, you didnt need to write _root.i in the first place as, because it is a button contained in root, i would refer to _root.i and not this.i anyway. If it was an MC you would have to.
    Last edited by DrDoom; 04-24-2006 at 12:33 PM.
    -luke.slashmedia.co.uk(my site)
    (^.^)

  7. #7
    Junior Member
    Join Date
    Mar 2001
    Posts
    21
    I have already tried to the best of my knowledge to apply the correct paths for the button to reference the i variable. This just will not work for me. I have tried to follow your comments the best I could but just nothing.

    I'm really sorry to keep asking but would you mind just having a quick look at my source? You might be able to see the issue.

    Cheers

  8. #8
    Junior Member
    Join Date
    Mar 2001
    Posts
    21
    OHH and heres the source

  9. #9
    Junior Member
    Join Date
    Mar 2001
    Posts
    21
    And again
    Attached Files Attached Files

  10. #10
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    Man, that took ages.

    But i've fixed it

    The problem was that you were using this.getNextHighestDepth instead of _level0.elev.tmp_mc.getNextHighestDepth, so it was creating the new MC on the same depth as the old one and the old one was being deleted.

    Heres the working source anyway
    Attached Files Attached Files
    -luke.slashmedia.co.uk(my site)
    (^.^)

  11. #11
    Junior Member
    Join Date
    Mar 2001
    Posts
    21
    Appologies for the late reply. Just wanted to say thanks, that has done the trick. So simple yet I was so far away!!!

    If I could I'd buy you a drink!

  12. #12
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    lol - im not even old enough to legally buy soft drinks in a bar
    -luke.slashmedia.co.uk(my site)
    (^.^)

  13. #13
    Junior Member
    Join Date
    Mar 2001
    Posts
    21
    God I'm getting old!!

  14. #14
    bCPro
    Join Date
    Jun 2006
    Location
    flashLand
    Posts
    5
    Hi Dr Doom,

    I've been reading the forum and I have a similar problem. Maybe your wide knowledge can help me ;-)
    I'm doing a website for an interior designer, I have multiple drag & drop objects to decorate a room.

    1- I need to duplicate the first object that the user drags just incase it is used again.
    2- I need to be able to apply colours and patterns to all duplicates.
    3- The example I'm using is based on frame labels which means to me that I need to have as many frame labels as combination of colours and patterns (quit a lot!!)

    I've done this kirupa's tutorial:
    http://www.kirupa.com/developer/acti...t/dragdrop.htm

    I've played with it changing a few scripts but just because I've got many combinations of colour and patterns I don't know how to work out the script. (I hope it makes sense!)

    I post the file just incase you want to have a look.

    Thanks in advance...

    A forum is my only hope!!!
    Attached Files Attached Files

  15. #15
    Junior Member
    Join Date
    Jun 2003
    Posts
    4
    I have almost the exact same problem as bCPro. Could someone post an authoritative example of how to set up a palette style menu? Thanks!

  16. #16
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    bCPro, heres the source for a working version. Basically, what i've done is made it so that the objects are duplicated instead of moved and the colours and patterns are applied separately (so you no longer need to have one frame for celestial-champagne, one for celestial-chocolate, one for barcode-champagne, one for barcode-chocolate etc. You can just set the colour MC and the pattern MC independently).

    Most of it should be pretty easy to understand, but if you dont get any of tell me and i can post an explanation.

    note to 17028 and anyone else:
    I wouldn't advise using the attached source as an example of palette style menu's as there's is still a LOT which could be improved. If I'd started this project myself i would have used a much more concise and orderly framework, but as im just replying to a post i can't really change the f/w that much.
    Attached Files Attached Files
    -luke.slashmedia.co.uk(my site)
    (^.^)

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