# Panning on Mouse

**URL:** <https://forum.kirupa.com/t/panning-on-mouse/274054>\
**Category:** flash\
**Created:** [October 24, 2008, 7:58am UTC](https://forum.kirupa.com/t/panning-on-mouse/274054 "2008-10-24T07:58:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mudasser\_abbas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@mudasser\_abbas](https://forum.kirupa.com/u/mudasser_abbas)\
**Post date:** [October 24, 2008, 7:58am UTC](https://forum.kirupa.com/t/panning-on-mouse/274054/1 "2008-10-24T07:58:17Z")

</div>

hi  
i m using this script to tween and auto pane images.  
now i want to make manual panning but i m new to flash.  
and stuck into problem please help me out.  
i will be very thankful to whom who will correct this code.  
import gs.TweenLite;

var mcl:MovieClipLoader = new MovieClipLoader();

var list:Object = new Object();  
mcl.addListener(list);  
//var myMovies:Array = new Array(“01.jpg”, “02.jpg”, “03.jpg”);  
stop();  
// Xml Image Node Attributes

var myMovies:Array = new Array();  
var arrImageBehavior:Array = new Array();  
var arrImageProperties:Array = new Array();  
var arrImageDuration:Array = new Array();

var myXML:XML = new XML();  
myXML.ignoreWhite=true;  
myXML.load(“Slides.xml”);  
myXML.onLoad = function(success)  
{  
if (success)  
{  
var myImage = myXML.firstChild.childNodes;  
for (i=0; i\<myImage.length; i++)  
{

```
            myMovies* = myXML.firstChild.childNodes*.attributes.ImageUrl;
            arrImageBehavior* = myXML.firstChild.childNodes*.attributes.Behavior;
            arrImageProperties* = myXML.firstChild.childNodes*.attributes.Properties;
            arrImageDuration* = myXML.firstChild.childNodes*.attributes.Duration;
    }
        
    loadSwfs();
}

```

}  
dupInterval  
var cont:Number = 0;  
function loadSwfs() {  
var ImgMc:MovieClip = createEmptyMovieClip(“target” + cont, getNextHighestDepth());  
loadEffects(ImgMc);  
Mouse.addListener(list);  
mcl.loadClip(myMovies[cont], eval(“target” + cont));

}

function loadEffects(ImgMc)  
{  
if(arrImageProperties[cont] == “Center Middle”)  
{  
TweenLite.from(ImgMc, 1, {\_x:0, \_y:0, \_xscale:100, \_yscale:100});  
TweenLite.to(ImgMc, arrImageDuration[cont], {\_x:-(Stage.width/2), \_y:-(Stage.height/2), \_xscale:200, \_yscale:200});  
}  
else //center to Top Left  
if(arrImageProperties[cont] == “Center Top Left”)  
{  
TweenLite.from(ImgMc, 1, {\_x:0, \_y:0, \_xscale:100, \_yscale:100});  
TweenLite.to(ImgMc, arrImageDuration[cont], {\_x:0, \_y:0, \_xscale:200, \_yscale:200});  
}  
else//Center -\> Middle Right  
if(arrImageProperties[cont] == “Center Middle Left”)  
{  
TweenLite.from(ImgMc, 1, {\_xscale:100, \_yscale:100});  
TweenLite.to(ImgMc, arrImageDuration[cont], {\_xscale:200, \_yscale:200});  
}  
else//Center -\> Top Right  
if(arrImageProperties[cont] == “Center Top Right”)  
{  
TweenLite.from(ImgMc, 1, {\_x:0, \_y:0, \_xscale:100, \_yscale:100});  
TweenLite.to(ImgMc, arrImageDuration[cont], {\_x:-(Stage.width/4), \_y:-(Stage.height/2), \_xscale:200, \_yscale:200});  
}

```
        else//Center -&gt; Middle Right
        if(arrImageProperties[cont] == "Center Middle Right")
        {
        TweenLite.from(ImgMc, 1, {_x:0, _y:0, _xscale:100, _yscale:100});
        TweenLite.to(ImgMc, arrImageDuration[cont], {_x:-(Stage.width/4), _y:-(Stage.height/4), _xscale:200, _yscale:200});
        }
        
        else//Center -&gt; Bottom Right
        if(arrImageProperties[cont] == "Center Bottom Right")
        {
        TweenLite.from(ImgMc, 1, {_x:0, _y:0, _xscale:100, _yscale:100});
        TweenLite.to(ImgMc, arrImageDuration[cont], {_x:-(Stage.width/4), _y:0, _xscale:200, _yscale:200});
        }
        //Auto Panning effects
        else//Left -&gt; Right
        if(arrImageProperties[cont]=="Left Right")
        {
        TweenLite.from(ImgMc, 1, {_x:-(Stage.width/4), _y:0, _xscale:100, _yscale:100});
        TweenLite.to(ImgMc, arrImageDuration[cont], {_x:0, _y:0, _xscale:100, _yscale:100});
        }
        else//Right -&gt; Left
        if(arrImageProperties[cont]=="Right Left")
        {
        TweenLite.from(ImgMc, 1, {_x:0, _y:0, _xscale:100, _yscale:100});
        TweenLite.to(ImgMc, arrImageDuration[cont], {_x:-(Stage.width/4), _y:0, _xscale:100, _yscale:100});
        }
        else//Top -&gt; Bottom
        if(arrImageProperties[cont]=="Top Bottom")
        {
        TweenLite.from(ImgMc, 1, {_x:0, _y:-(Stage.height/4), _xscale:100, _yscale:100});
        TweenLite.to(ImgMc, arrImageDuration[cont], {_x:0, _y:0, _xscale:100, _yscale:100});
        }
        else//Bottom -&gt; Top
        if(arrImageProperties[cont]=="Bottom Top")
        {
        TweenLite.from(ImgMc, 1, {_x:0, _y:(Stage.height/4), _xscale:100, _yscale:100});
        TweenLite.to(ImgMc, arrImageDuration[cont], {_x:0, _y:0, _xscale:100, _yscale:100});
        }

```

}

list.onLoadInit = function() {  
mcl.unloadClip( eval(‘target’ + [2,0,1][cont]));  
cont = (cont + 1);  
setTimeout(loadSwfs, arrImageDuration[cont]\*100);

}  
list.onLoadComplete = function(ImgMc)  
{  
if(cont \> myMovies.length)  
{  
trace("Movie: " + ImgMc );

```
}
else
{
    trace("Value of Cont is: " + cont);
}

```

};  
myXMl.onLoadComplete = function(){  
trace("Value of Cont One: " + cont);  
}

list.onMouseMove = function()  
{  
trace(“On Mouse Move” + ImgMc);  
constrainedMove(ImgMc, 4, 1);  
}  
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {  
var mousePercent:Number = \_xmouse/Stage.width;  
var mSpeed:Number;  
if (dir == 1) {  
mSpeed = 1-mousePercent;  
} else {  
mSpeed = mousePercent;  
}  
target.destX = Math.round(-((target.\_width-Stage.width)_mSpeed));  
target.onEnterFrame = function() {  
if (target.\_x == target.destX) {  
delete target.onEnterFrame;  
} else if (target.\_x\>target.destX) {  
target.\_x -= Math.ceil((target.\_x-target.destX)_(speed/100));  
} else if (target.\_x\<target.destX) {  
target.\_x += Math.ceil((target.destX-target.\_x)\*(speed/100));  
}  
};  
}
