Re: [Flashcoders] pythagoras question

2008-08-27 Thread Hans Wichman
Hi, I don't think pythagoras is involved here. try: factor = vectorLength/c; coordX = startX + (endX-startX)*factor; coordY = startY + (endY-startY)*factor; greetz JC On Wed, Aug 27, 2008 at 7:00 PM, allandt bik-elliott (thefieldcomic.com) <[EMAIL PROTECTED]> wrote: > hi guys > > I'm doing som

RE: [Flashcoders] pythagoras question

2008-08-27 Thread Steve Abaffy
It sounds to me like your trying to find the x,y coordinates along a line. If this is the case then: M = (starty-endy)/(startx-endx) and B = -startx + starty Then Y = m*x + b where x is the current x location of the train and y will be the y-coordinate of the train. I hope this helps. -Orig

RE: [Flashcoders] pythagoras question

2008-08-27 Thread Merrill, Jason
Why not just use Point.polar()? That would do exactly what it seems you are describing. Jason Merrill Bank of America Enterprise Technology & Global Risk L&LD Instructional Technology & Media Join the Bank of America Flash Platform Developer Community Are you a Bank of America associate int

Re: [Flashcoders] pythagoras question

2008-08-30 Thread Arka Roy
I think this is what you need. --- angle = Math.atan2( endY - startY, endX - startX ); trainX = vectorLength * Math.cos( angle ); trainY = vectorLength * Math.sin( angle ); --- Notes: 1. I'm using atan2(), not atan(). 2. The function atan2() takes (endY - startY) as its fi

Re: [Flashcoders] pythagoras question

2008-08-30 Thread Weyert de Boer
May I ask a related question? How can I detected if a user has clicked on a line (or later a bezier path) ? I am having the starting and ending coordinates of this line and so also the distance. Now I am would like to check if the user has clicked within this line with/or without a specific radi

Re: [Flashcoders] pythagoras question

2008-08-30 Thread Arka Roy
Let's call the position of the mouse click on the stage (clickedX, clickedY) The starting coordinates are (startX, startY) The ending coordinates are (endX , endY) The general equation of your line, for any variables X and Y, is: Y == (X - startX) * (endY - startY) / (endX - startX) So when the u

RE: [Flashcoders] pythagoras question

2008-08-30 Thread Merrill, Jason
ugust 30, 2008 8:19 AM To: Flash Coders List Subject: Re: [Flashcoders] pythagoras question May I ask a related question? How can I detected if a user has clicked on a line (or later a bezier path) ? I am having the starting and ending coordinates of this line and so also the distance. Now I

Re: [Flashcoders] pythagoras question

2008-08-31 Thread Weyert de Boer
Merrill, Jason wrote: A simple solution could be to create a sprite to draw the line onto, and add a listener to the sprite to see if it was clicked on. Yes, but then you still have the problem that a two pixel line is not a great hit area for drawn line. That's why I asked the question to im

Re: [Flashcoders] pythagoras question

2008-08-31 Thread Ivan Dembicki
Hello, > Yes, but then you still have the problem that a two pixel line is not a > great hit area for drawn line. [...] - also you can draw 5 pixel transparent line. like this: http://bezier.ru/wp-content/uploads/2008/06/bezier.swf?demo=3 -- iv http://www.bezier.ru http://bezier.googlecode.com

Re: [Flashcoders] pythagoras question

2008-08-31 Thread allandt bik-elliott
IL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Weyert de Boer Sent: Saturday, August 30, 2008 8:19 AM To: Flash Coders List Subject: Re: [Flashcoders] pythagoras question May I ask a related question? How can I detected if a user has clicked on a line (or later a bezier path) ? I am having the

Re: [Flashcoders] pythagoras question

2008-08-31 Thread dr.ache
Expand the idea of Jason and draw an invisible rectangle "under" your specific line. Assumed your line should be 30px long and your click radius should be 5xp var line:Sprite = new Sprite(); var g:Graphics = line.graphics; g.clear(); // hit radius *g.beginFill(0xff,0);* g.drawRect(0,-3,30,5);