troubleshooting Question

Find Middle of line

Avatar of GTsafas
GTsafas asked on
Adobe Flash
7 Comments2 Solutions278 ViewsLast Modified:
I need to find the middle of this line and follow it.

When I move the mouse I want an item to follow along the center of the line that corresponds with the mouses x. I dont care if this is the whole stage or just when the mouse is inside the line itself.

But it needs to give leeway from the center, so that you dont have to trace it exactly.

Any help is appreciated, thanks

	import flash.display.*;
	import flash.text.TextField;
	public class Main extends Sprite 
		public function Main():void 
				var lineDrawing:Sprite = new Sprite();, 0x0000FF);,0);, 600);, 400);
				lineDrawing.addEventListener(MouseEvent.MOUSE_MOVE, mse_over);
		//		var square:Sprite = new Sprite();
		//		addChild(square);
				var label:TextField = new TextField();
				function mse_over(event:MouseEvent):void
							label.autoSize = "left";
							label.text = mouseX.toString() + "," + mouseY.toString();
							//label.x = ;
							//label.y = "";
							square.x = 5 + mouseX;
							square.y = mouseY - 66;
Gary Benade

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros