A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23

Thread: Drag and Drop OS-style

  1. #21
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    No problem. If i'm understanding you correctly, you want the movieclip to be on top of all other clips when it's clicked anywhere, even if the aClip isn't clicked, right?

    If that's the case, then use this:

    Code:
    import flash.geom.Rectangle;
    for (var i:uint = 1; typeof(this["dmc_"+i]) != "undefined"; i++) {
    	this["dmc_"+i].aClip.addEventListener(MouseEvent.MOUSE_DOWN, startD);
    	this["dmc_"+i].aClip.addEventListener(MouseEvent.MOUSE_UP, stopD);
    	this["dmc_"+i].addEventListener(MouseEvent.CLICK, mUp);
    }
    
    function mUp(evt:MouseEvent):void {
    	this.setChildIndex(MovieClip(evt.currentTarget), this.numChildren - 1);
    }
    function startD(evt:MouseEvent):void {
    	var rect:Rectangle = new Rectangle(0, 0, stage.stageWidth-evt.currentTarget.parent.width, stage.stageHeight-evt.currentTarget.parent.height);
    	evt.currentTarget.parent.startDrag(false, rect);
    	this.setChildIndex(MovieClip(evt.currentTarget.parent), numChildren - 1);
    }
    function stopD(evt:MouseEvent):void {
    	evt.currentTarget.parent.stopDrag();
    }

  2. #22
    Member
    Join Date
    Aug 2009
    Posts
    41
    That worked like a charm! You are a genius.

    Thank you very much!

  3. #23
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Thanks, always happy to help.

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