# How to create a mouse click and drag for multiple movieclips which ar image sequences

**URL:** https://forum.kirupa.com/t/how-to-create-a-mouse-click-and-drag-for-multiple-movieclips-which-ar-image-sequences/331599
**Category:** flash
**Created:** [September 7, 2013, 2:21pm UTC](https://forum.kirupa.com/t/how-to-create-a-mouse-click-and-drag-for-multiple-movieclips-which-ar-image-sequences/331599 "2013-09-07T14:21:59Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kittu](https://avatars.discourse-cdn.com/v4/letter/k/4491bb/32.png) [@kittu](https://forum.kirupa.com/u/kittu)
#### Post date: [September 7, 2013, 2:21pm UTC](https://forum.kirupa.com/t/how-to-create-a-mouse-click-and-drag-for-multiple-movieclips-which-ar-image-sequences/331599/1 "2013-09-07T14:21:59Z")

</div>

Hi All,  
I have myself in a situation where everything was perfect with mouse click and drag, keyboard events and zoom events.The project is:

A movieclip with images sequence: For Original background.  
And other movieclips: aslo images sequence (Pngs)

They were all given separate mouse events and zoom and key events.

Now wen I click the button with concerned movieclip to function, only the png image seuence is rotating and the main mc is not.

What should I do to rotate both the activated whichever png mcs and main mc also with these.

I have this for every button and a mouse event and key event and zoom event added.

**Below is the button function:**

```auto

 
garage_horizon_btn.addEventListener(MouseEvent.CLICK,garage)
function garage(event:MouseEvent):void
{
 garage_horizon_mc.gotoAndStop(rotationframe);
 garage_horizon_mc.visible=true;
 garage_horizon_mc.stop();
 garage_moss_mc.visible=false;
 garage_ocean_mc.visible=false;
 gutter_ocean_mc.visible=false;
 gutter_horizon_mc.visible=false;
 gutter_moss_mc.visible=false;
 main_mc.visible=false;
}

```

**Below is the Mouse Event.**

```auto
var rotationframe:int = 1;
var rotater:MovieClip = images_mc.garage_horizon_mc;
var offsetFrame:int = rotater.currentFrame;
var offsetX:Number = 0;
var percent:Number = 0;
rotater.addEventListener(MouseEvent.MOUSE_DOWN,startDragging);
rotater.addEventListener(MouseEvent.MOUSE_UP,stopDragging);
function startDragging(e:MouseEvent):void
{
    rotater.addEventListener(MouseEvent.MOUSE_MOVE,drag);
    offsetX = e.target.mouseX;
}
function stopDragging(e:MouseEvent):void
{
    rotater.removeEventListener(MouseEvent.MOUSE_MOVE,drag);
    offsetFrame = rotater.currentFrame;
}
function drag(e:MouseEvent):void
{
    percent = (e.target.mouseX - offsetX)/rotater.width;
    var frame:int = Math.round(percent*rotater.totalFrames) + offsetFrame +1;
    while (frame>rotater.totalFrames)
    {
        frame -= rotater.totalFrames;
    }
    while (frame<=0)
    {
        frame += rotater.totalFrames;
    }
    rotater.gotoAndStop(frame);
    rotationframe = images_mc.garage_horizon_mc.currentFrame;
}

```

Please help.

Thanks in advance.
