A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: SwapDepth of duplicate

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    3

    SwapDepth of duplicate

    Hello! I'm fairly new to coding with flash and have been using AS2. I've had a lot of annoying problems along the way but have managed to figure things out in the end until now. I've been stumped on something for awhile and am just not sure how to proceed any further.

    I am creating a simple dressup game where one is able to drag and drop duplicated movieclips from around the scene and place them overtop of a 'body'

    Some of the 'objects' one is meant to drag are partially hidden behind other things. Is there a way to make duplicates come to the front using something like...this.swapDepths(this._parent.getNextHighestDepth() ); while keeping the original object's Depth intact?

    Meaning If I have a 'circle' hidden half way behind a 'rectangle'..I want to be able to drag multiple duplicates of the circle away from the original. The duplicates should layer overtop of the 'rectangle' as I drag them around, but the original 'circle' should stay behind it.

    Here's the code I'm currently using to duplicate things x_o

    Actionscript Code:
    mymc.onPress = function() {
        var newmymc:MovieClip = this.duplicateMovieClip("mymc"+this.copies, this._parent.getNextHighestDepth());
        newmymc.startDrag();
        newmymc.onPress = startDrag;
        newmymc.onRelease = this.onReleaseOutside = stopDrag;
    };

    any suggestions would be really appreciated

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    that shoudl work fine..

    actionscript Code:
    mymc.onPress = function() {
        var newmymc:MovieClip = this.duplicateMovieClip("mymc"+this.copies, this._parent.getNextHighestDepth());
        newmymc.startDrag();
        newmymc.onPress = function(){
            this.swapDepths(this._parent.getNextHighestDepth());
            startDrag;
        }
        newmymc.onRelease = this.onReleaseOutside = stopDrag;
    };

  3. #3
    Junior Member
    Join Date
    Feb 2011
    Posts
    3
    thank you that definitely helped keep the original behind the overlapping MC . However now the duplicates cannot be dragged again once they've been placed :x

  4. #4
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    try using the corredtc syntax.. I was only posting a suggestion


    startDrag;

    to this:

    this.startDrag();

    perhaps?

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