True center of a clip?

I want to find the true center of a clip

 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

 Stage.**_**width/2

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

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

 
**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?

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

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…?

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…

I just changed it to

_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

:wink:

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:

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

scotty(-:

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

but if i do this

  
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?

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.