# True center of a clip?

**URL:** <https://forum.kirupa.com/t/true-center-of-a-clip/109433>\
**Category:** Uncategorized\
**Created:** [May 5, 2004, 3:12pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433 "2004-05-05T15:12:40Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![simpleSoft](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@simpleSoft](https://forum.kirupa.com/u/simpleSoft)\
**Post date:** [May 5, 2004, 3:12pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433/1 "2004-05-05T15:12:40Z")

</div>

I want to find the true center of a clip

```auto
 Stage.width/2 

```

Does not do it. I have attached an example I want to find the cursor’s distance from the blue line (center) at any point. But as you will see if you compile what i have its just a little offCenter.

If you compile it move the cursor around I a have sometext boxes on the stage that show all the vital stats, X mouse pos, center, distance from center, etc…

BTW this will be a scroller at one point so all that other stuff in the code will one day effect that. Any help would be awsome

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2004, 3:19pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433/2 "2004-05-05T15:19:16Z")

</div>

```auto
 Stage. **_** width/2

```

?  
Can’t see your source, but that might make a difference…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2004, 3:23pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433/3 "2004-05-05T15:23:43Z")

</div>

The Stage property only has the width property not \_width, it throws an error.

```auto
 
**Error** Scene=Scene 1, 
layer=Layer 2, frame=1:Line 2: 
There is no property with the 
name '_width'.
 
var center:Number = new Number(Stage._width/2);
 
Total ActionScript Errors: 1 Reported Errors: 1 

```

And why can’t you see my code did I attach it wrong or something?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2004, 3:26pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433/4 "2004-05-05T15:26:44Z")

</div>

At work. No downloading… 😛  
Um… you have an MC, and you’re trying to determine it’s center?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2004, 3:30pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433/5 "2004-05-05T15:30:10Z")

</div>

Well what I am doing is going to make a opposite image scroller, and I am going to base the speed of the scroller off of the mouse’s position compared to the center…but when I view my MC (where I drew a blue line at dead center) and put my mouse over the blue line…it says that my X pos is 42px away from center…how could this be…?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2004, 3:37pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433/6 "2004-05-05T15:37:44Z")

</div>

hmm…  
If you’re using an MC, than \_width should be valid… you can say \_root.Mc\_name.\_width or this.\_width, and it _should_ work…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2004, 3:40pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433/7 "2004-05-05T15:40:55Z")

</div>

I just changed it to

```auto
_root._width/2

```

…and that got me to my line but now when I move the thing around it is just crazy I have no idea what it is doing now…

Sometimes the clip will scroll to the left and then jump right back to center or wierd things like that…::sigh:: Nothing ever goes perfectly the way it should

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2004, 3:46pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433/8 "2004-05-05T15:46:54Z")

</div>

> [@Zedd](#):
>
> “Nothing’s ever easy.”

😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2004, 5:52pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433/9 "2004-05-05T17:52:38Z")

</div>

Stage.width/2 givesyou the center of your movie , put a trace and it will give 275;)  
Where you define the offCenter in the onMouse you refer to barMenu.\_xmouse, there it is going wrong. Change it in:

```auto
offCenter = _root._xmouse-center;trace(offCenter);

```

scotty(-:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2004, 6:11pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433/10 "2004-05-05T18:11:21Z")

</div>

ok well here is my next problem then I want the menu to never show the edges…

but if i do this

```auto
  
if(offScreen_right<0) {
} else if (offScreen_left<0){
} else {
	 this._x += (offCenter-this._x)/10;
}

```

But what ends up happening is that it gets to the edges and stops and never goes back into the loop…I want it to get the edges and stop scrolling, but if I move the mouse then I want it to scroll again. Do you get me?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2004, 6:18pm UTC](https://forum.kirupa.com/t/true-center-of-a-clip/109433/11 "2004-05-05T18:18:27Z")

</div>

Also, i tried changing you line of code…well if you do that. Try and see when the mouse is at the center or the difference is 0. (It is somewhere to the right)So i don’t think that, that is right…? Cause I tried it that way too…and for somereason it never is the true center of the clip.
