[Flashcoders] rotate along a path using sine curve

2011-05-26 Thread allandt bik-elliott (thefieldcomic.com)
hey folks

i'm trying to get some objects to move along a sine curve on the z axis but
i'm having a bit of trouble with the rotationY - i'd like the objects to
align along the path so they're always facing 90 degress to the direction
they're travelling but they seem to want to keep rotating in circles

(note file is 800 x 600)

here's my code:
package
{
//imports
 public class CarouselTest extends Sprite
{
public static const SPACING : int = 20;
public static const SPEED : Number = .05;
public static const XSPEED : Number = 800 / 360 * 2;
public static const RADIUS : int = 400;
 private var _items:Array;
private var _container:Sprite;
 public function CarouselTest()
{
_items = new Array();
 _container = new Sprite();
_container.x = 400;
_container.y = 300;
addChild(_container);
 var item:CarouselItem = new CarouselItem();
for (var i:int = 0; i  200; i++)
{
item = new CarouselItem();
item.angle = i * SPACING;
item.x = i * SPACING * 5 - 1000; // move into desired position
item.speed = SPEED;
_container.addChild(item);
_items.push(item);
}
 addEventListener(Event.ENTER_FRAME, handleEnterFrame);
}
 private function handleEnterFrame(e:Event):void
{
var item:CarouselItem;
for (var i:int = 0; i  _items.length; i++)
{
item = _items[i] as CarouselItem;
item.angle += SPEED;
item.z = Math.sin(item.angle) * RADIUS;
item.rotationY = Trig.radiansToDegrees(item.angle)  * -1; // this is the
area i'm stuck on
item.x += XSPEED;
}
 SimpleZSorter.sortClips(_container); // thankyou mr papervision and lee
brimelow
}
 }

}

hope you can help
A
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] rotate along a path using sine curve

2011-05-26 Thread allandt bik-elliott (thefieldcomic.com)
Hey Cor

What else would you need?
On May 26, 2011 9:20 PM, Cor c...@chello.nl wrote:
 Allandt,

 Can you send me the necessary source so I can look into it?

 Regards,
 Cor van Dooren


 -Original Message-
 From: flashcoders-boun...@chattyfig.figleaf.com
 [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of allandt
 bik-elliott (thefieldcomic.com)
 Sent: donderdag 26 mei 2011 18:52
 To: Flash Coders List
 Subject: [Flashcoders] rotate along a path using sine curve

 hey folks

 i'm trying to get some objects to move along a sine curve on the z axis
but
 i'm having a bit of trouble with the rotationY - i'd like the objects to
 align along the path so they're always facing 90 degress to the direction
 they're travelling but they seem to want to keep rotating in circles

 (note file is 800 x 600)

 here's my code:
 package
 {
 //imports
 public class CarouselTest extends Sprite { public static const SPACING :
 int = 20; public static const SPEED : Number = .05; public static const
 XSPEED : Number = 800 / 360 * 2; public static const RADIUS : int = 400;
 private var _items:Array; private var _container:Sprite; public function
 CarouselTest() { _items = new Array(); _container = new Sprite();
 _container.x = 400; _container.y = 300; addChild(_container); var
 item:CarouselItem = new CarouselItem(); for (var i:int = 0; i  200; i++)
{
 item = new CarouselItem(); item.angle = i * SPACING; item.x = i * SPACING
*
 5 - 1000; // move into desired position item.speed = SPEED;
 _container.addChild(item); _items.push(item); }
 addEventListener(Event.ENTER_FRAME, handleEnterFrame); } private function
 handleEnterFrame(e:Event):void { var item:CarouselItem; for (var i:int =
0;
 i  _items.length; i++) { item = _items[i] as CarouselItem; item.angle +=
 SPEED; item.z = Math.sin(item.angle) * RADIUS; item.rotationY =
 Trig.radiansToDegrees(item.angle) * -1; // this is the area i'm stuck on
 item.x += XSPEED; } SimpleZSorter.sortClips(_container); // thankyou mr
 papervision and lee brimelow } }

 }

 hope you 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