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 improve the experience by calculating the hit area myself. I can 
basically check if the click is within the given radius of the line.

If so, recognize the click as clicked on the line.


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


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
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] pythagoras question

2008-08-31 Thread allandt bik-elliott

yeh - that's what i did


On 30 Aug 2008, at 21:10, 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.

Jason Merrill
Bank of America
Enterprise Technology  Global Risk LLD
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  Innovative Learning Blog  subscribe.

-Original Message-
From: [EMAIL 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 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 radius. I am currently a bit clueless how  
to

solve this problem.

I know it's close what you have given earlier.

Yours,
Weyert
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


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);
g.endFill();
// line itself
*g.beginFill(0x00,1);
g.drawRect(0,0,30,1);*
g.endFill();

Notice that the hit radius has an alpha of zero and
the line an alpha of 1. Does it work for you?


Weyert de Boer schrieb:

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 improve the experience by calculating the hit area myself. I can 
basically check if the click is within the given radius of the line.

If so, recognize the click as clicked on the line.


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


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 first parameter, and
(endX - startX) as its second.  It's easy to make the mistake of assigning
them the other way round.

Hope this helps.
A


On Thu, Aug 28, 2008 at 2:00 AM, allandt bik-elliott (thefieldcomic.com) 
[EMAIL PROTECTED] wrote:

 hi guys

 I'm doing something wrong in my pythagoras theorum but i'm not seeing what
 it is right now

 i'm trying to find out the coordinates for a point on a line. I know the
 start x, end x, start y, end y, c length for the line and i know how far
 along c the point should be (call it vector length) but i'm a little
 stumped
 as to where to go from there

 the psuedo code for what i've been trying is

 vector x = start x / end x
 vector y = start y / end y
 train x = (vector x * vector length) + start x
 train y = (vector x * vector length) + start y

 I think i have my maths very wrong here - hope you guys can help

 a
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


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 radius. I am currently a bit clueless how to 
solve this problem.


I know it's close what you have given earlier.

Yours,
Weyert
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


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 user clicks on the stage, the values of clickedX and clickedY
would need to satisfy the following equation:
clickedY == (clickedX - startX) * (endY - startY) / (endX - startX)

If this is true for clickedX and clickedY then that means the click fell on
the line.  Of course you would probably have to provide a bit of an error
margin because you can't accurately evaluate the equality (==) of real
numbers.

A



On Sat, Aug 30, 2008 at 9:18 PM, Weyert de Boer [EMAIL PROTECTED] wrote:

 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 radius. I am currently a bit clueless how to
 solve this problem.

 I know it's close what you have given earlier.

 Yours,
 Weyert

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] pythagoras question

2008-08-30 Thread Merrill, Jason
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.

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  Innovative Learning Blog  subscribe. 

-Original Message-
From: [EMAIL 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 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 radius. I am currently a bit clueless how to 
solve this problem.

I know it's close what you have given earlier.

Yours,
Weyert
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


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 something wrong in my pythagoras theorum but i'm not seeing what
 it is right now

 i'm trying to find out the coordinates for a point on a line. I know the
 start x, end x, start y, end y, c length for the line and i know how far
 along c the point should be (call it vector length) but i'm a little stumped
 as to where to go from there

 the psuedo code for what i've been trying is

 vector x = start x / end x
 vector y = start y / end y
 train x = (vector x * vector length) + start x
 train y = (vector x * vector length) + start y

 I think i have my maths very wrong here - hope you guys can help

 a
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


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.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of allandt
bik-elliott (thefieldcomic.com)
Sent: Wednesday, August 27, 2008 12:00 PM
To: Flash Coders List
Subject: [Flashcoders] pythagoras question

hi guys

I'm doing something wrong in my pythagoras theorum but i'm not seeing what
it is right now

i'm trying to find out the coordinates for a point on a line. I know the
start x, end x, start y, end y, c length for the line and i know how far
along c the point should be (call it vector length) but i'm a little stumped
as to where to go from there

the psuedo code for what i've been trying is

vector x = start x / end x
vector y = start y / end y
train x = (vector x * vector length) + start x
train y = (vector x * vector length) + start y

I think i have my maths very wrong here - hope you guys can help

a
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


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 LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  Innovative Learning Blog  subscribe. 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of allandt
bik-elliott (thefieldcomic.com)
Sent: Wednesday, August 27, 2008 1:00 PM
To: Flash Coders List
Subject: [Flashcoders] pythagoras question

hi guys

I'm doing something wrong in my pythagoras theorum but i'm not seeing
what
it is right now

i'm trying to find out the coordinates for a point on a line. I know the
start x, end x, start y, end y, c length for the line and i know how far
along c the point should be (call it vector length) but i'm a little
stumped
as to where to go from there

the psuedo code for what i've been trying is

vector x = start x / end x
vector y = start y / end y
train x = (vector x * vector length) + start x
train y = (vector x * vector length) + start y

I think i have my maths very wrong here - hope you guys can help

a
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders