# Object Wrap

**URL:** https://forum.kirupa.com/t/object-wrap/105824
**Category:** Uncategorized
**Created:** [March 30, 2004, 4:47am UTC](https://forum.kirupa.com/t/object-wrap/105824 "2004-03-30T04:47:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![hondo311](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@hondo311](https://forum.kirupa.com/u/hondo311)
#### Post date: [March 30, 2004, 4:47am UTC](https://forum.kirupa.com/t/object-wrap/105824/1 "2004-03-30T04:47:35Z")

</div>

I’ve been fooling with a horizontal scroller. Attached is the fla. and code below.

I’m not too good with the math . . .

It seems to scroll ok forwards and back, BUT, when the strip repeats (so #1 comes back around again after #5) it seems to skips right to #2

Also, it would be cool if it would jump to the nearest full square when you stop cranking.  
hmmm . . . any thoughts?

## Thanks!!

MovieClip.prototype.objectWrap = function(MinX,MaxX,MinY,MaxY){  
// check the X.  
if(this.\_x \>= MaxX){  
this.\_x -= MaxX;  
}else if(this.\_x \<= MinX){  
this.\_x += MaxX;  
}  
/////check the Y.  
if(this.\_y \>= MaxY){  
this.\_y -= MaxY;  
}else if(this.\_y \<= MinY){  
this.\_y += MaxY;  
}  
};

mc.btn.onPress = function(){  
scrolling = true;  
[//mc.btn](https://mc.btn) is the crank and buton–mc is just the crank  
}  
mc.btn.onRelease = mc.btn.onReleaseOutside = function(){  
scrolling = false;  
}  
onEnterFrame = function(){  
if(scrolling){  
var dx=\_xmouse-mc.\_x;  
var dy=\_ymouse-mc.\_y;  
var r = Math.atan2(dy,dx);  
if(r \>= Math.PI_2) r-=Math.PI_2;  
if(r \< 0)r+=Math.PI_2;  
var oa = a;  
a = (r_180)/Math.PI;  
var da = a-oa;  
mc.\_rotation=a;  
if(Math.abs(da) \> 180) da = 0;

```
ball2._x += da&lt;&lt;1;
ball2._y += Math.cos(r)*0;

ball2.objectWrap(-352,352,-352,352);
//352 is the number of pixels that pass through the mask before it should repeat---each number square is 88 pixels wide
}

```

};
