Skip navigation
Currently Being Moderated

Curved Path with actionscript

Apr 2, 2013 7:47 PM

Tags: #as3 #3.0 #action_script_3 #actionscript #flash_professional #animation #actions #flash_cs6

Hi I am building my first game. I'm aming to keep all code in seperate actionscript files (one for each class and a main constructor .as) linked to my fla.


So far I have added the backgound movieclip and one moving object (mc). i.e. 2 class files) It all looks great so far.


In my game I have a projectile (first of many) falling out of a specific x;y point. I have a timer to change the x;y positions. This works well but it is going in a straight line.From parabola formulas I know y = x^2 or y = x*x, but these don't work.


1) Please tell me what code to use to make a projectile's path curved or do I need a physics engine to handle this? Any ointers to tutorials will be much appreciated.

2) I'm going to have many of these items fall out from the same x;y coordinates but i'd like the curve to vary. So I suppose I must add a random number to the formula - i. How do I do that? In normal life I would do y = x^2 + i.

3) The "falling projectiles" are all going to match letters of the alphabet, so I suppose I will not have different instances of the same movieclip but rather different classes for each letter. Am I on the right path? How taxing will this be on my swf file size?


Here is the very basic, but perfectly working code so far:

    import flash.display.MovieClip;
    public class A extends MovieClip
        public function A()
            x = 300;
            y = 30;
            alpha = 0.1;


        public function fadeIn():void
            alpha = alpha + 0.06;


        public function moveWithCurve():void
            x = x + 3;
            y = y + 4;


Message was edited by: buggerschool


More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points