0
votes

So what I am trying to do is I have a movieclip that loads from an external swf file. I want to be able to drag this movieclip. I will have multiple instances of draggable movieclips and that's why having seperate dragging codes for each on the main timeline is not what I really want. I want the actionscript to be inside that swf to be run from the main timeline (root). How can I adapt this code inside the movieclip?

import flash.events.MouseEvent;

this.addEventListener(MouseEvent.MOUSE_DOWN, startDragging, true);
this.addEventListener(MouseEvent.MOUSE_UP, stopDragging, true);

function startDragging(e:MouseEvent) {
object.startDrag();
}

function stopDragging(e:MouseEvent) {
object.stopDrag();
}

Also what I would like to do is to be able to drag the whole contents of the movieclip from one area of that movieclip, or to be more specific, I want to have a hotspot in that movieclip that will work with the stardrag.

1

1 Answers

0
votes

Enter the code below inside your movie clip.

stage.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
stage.addEventListener(MouseEvent.MOUSE_UP,  onUp);

function onDown(e:MouseEvent):void
{
    if(e.target == this)
      this.startDrag();
}

function onUp(e:MouseEvent):void
{
    this.stopDrag();
}