Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: Re: [flasher] constraining drag along angle
From: Helen Triolo
Date: Mon, 26 Feb 2001 18:30:53 -0000

Matt,

If you constrain your mc drag to a square and then use

this._y = this._x;

in your onClipEvent(enterFrame) --or whatever kind of loop or routine
you use to move the object-- that should keep it moving only along a 45
degree line inside the square.

If you need a different angle (specified in degrees between 0 and 90),
you'd need something like

this._y = (this._x * Math.tan(angle*Math.PI/180));

(or maybe subtract the value on the right from the height of the
constraining rectangle to get it to move from lower left to upper
right).

The math behind this is tan(angle-in-radians) = y/x, and to convert an
angle in radians to an angle in degrees, you multiply by pi and divide
by 180. A good reference page for this is
http://www.npac.syr.edu/REU/reu94/williams/ch1/section3_4.html

Regards,
Helen
-------------------------------------------------------------------
1240 Flash Answers from 424 people: http://i-technica.com/flashlist

Matt wrote:
>
> Hi,
>
> Does anyone know how to create a draggable MC, that would slide along an
> angled axis, say, 45 degrees? So that when you moved your mouse back and
> forth along the x-axis, the MC would slide in lockstep with the X, but
> along a 45 degree angle on the Y? does anyone know of examples of this?
>
> TIA,
>
> Matt



[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]