|
-
Find MC center relative to edges?
This seems like a simple question, but I don't seem to be able to find the right wording to find my answer anywhere.
How do I determine where an MC's center is relative to its edges?
I'm developing a tool that a variety of noobs (as if I'm not still a noob) will be using, and I don't trust them to keep art with 0,0 being the top left corner.
How do I figure out that the left edge is now at -111px, and the top at -52, and the right at 12, and the bottom at 334?
Or what if they draw it so the left edge is at 56px and the right edge at 583?
Essentially, I want to determine the center of my artwork, wherever it is relative to the center of the MC
-
Flash/Flex Developer
I totally sure I understand what you want, but to figure out the center of a MC, you simply take half of the MC's width, like so:
mcXCenter = mc.width / 2;
mcYCenter = mc.height / 2;
That will give you the exact center of the movieclip, regardless where the relative point has been placed on the movieclip. It becomes tricky when you are moving the object around. Because you don't know if the center or left of the MC is identified as the origin point, then when you adjust your position based on the center point, you may be moving the object half its width/height in the wrong direction.
Does that make sense?
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
Yeah what I'm trying to do is move my MC around, and scale it and center it. So my goal is to figure out where the actual center is vs the MC's center.
At the moment I've worked around it by placing a SizerMC inside my MC, which the user has to scale to encompass all their art.
Its working fine now, but it would be cool to know how to determine where art is in an MC vs its center
-
Flash/Flex Developer
Well my first post will should you how to find the center of the particular MC, that along with getting the center of the stage, will center the MC. For example:
Actionscript Code:
mc.x = (stage.stageWidth / 2) - (mc.width / 2); mc.y = (stage.stageHeight / 2) - (mc.height / 2);
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|