A Flash Developer Resource Site

1. ## Angle Question

Hi,

i am following a tutorial from a book, Learning Actionscript 3.0, A Beginners Guide, where it discusses how to move an object in an agle. I have managed to get the app working fine, but i'm tryin to test it out in different angles but everytime i change it seems to go into the same angle. Here is the code listings:

Code:
```package
{

/**
* MoveAngle.as is meant to show you can move an object i.e a ball, along an angle
* @author Luong Vuong
* Date created: 26/11/2009
*/

import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;

public class MoveAngle extends Sprite
{
private var ball:MovieClip;

private var speed:Number;
private var angle:Number;
private var xVel:Number;
private var yVel:Number;

public function MoveAngle() :void
{
ball = new Ball();
ball.x = ball.y = 100;

speed = 12;
angle = 10;

construct();
}

public function construct() :void
{

}

public function onLoop(evt:Event) :void
{
ball.x += xVel;
ball.y += yVel;
}

{
return deg * (Math.PI / 180);
}

}

}```
Can somebody tell me why for everytime i changed the value of the degrees, it does not updat the movement of the ball please.

P.S i'm using FlashDevelop
Thanks

2. You are using cosine for both x and y. The y velocity should be using sine instead. If they are both using the same, then xVel and yVel will have the same value, and the slope of the line will be 45 degrees.

3. Originally Posted by 5TonsOfFlax
You are using cosine for both x and y. The y velocity should be using sine instead. If they are both using the same, then xVel and yVel will have the same value, and the slope of the line will be 45 degrees.
AAH DOH!!! sorry, i just realised it after you had posted. I looked in the book and yes, it had x value for cos and y value for sin. Apoligise for the minor mistake and thanks for pointing it out.

Cheers

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap