Skip to main content
Participant
April 19, 2013
Answered

Parabola AS3

  • April 19, 2013
  • 1 reply
  • 1119 views

Hi I'm a student doing an assignment where I need to animate an arrow flying to a falling target. As this is for a physics subject it needs to be in a lifelike environment hence using functions instead of motion tweening. I am new to AS3 and have some code that should use a parabola function to animate the flying arrow. I am getting three errors at the moment:

  • Line 6 1084: Syntax error: expecting leftbrace before semicolon.
  • Line 56 1084: Syntax error: expecting rightbrace before end of program.
  • Line 56 1084: Syntax error: expecting rightbrace before end of program.

Here is the code:

package

{

          import flash.display.Sprite;

          import flash.display.MovieClip;

          {

                    public class Arrow extends MovieClip;

                    {

                        public static const g:Number = 10;

                                  //our arrow

                                  private var arrow:Shape;

                        //start velocities

                        private var ux:Number;

                        private var uy:Number;

                        public function Arrow()

                        {

                            arrow = new Shape();

                            arrow.graphics.lineStyle( 1, 0 );

                                     arrow.graphics.lineTo( 30, 0 );

                        }

                        public function fire( vx:Number, vy:Number ):void

                        {

                            ux = vx;

                            uy = vy;

                            addChild( arrow );

                            addEventListener( Event.ENTER_FRAME, fly );

                        }

                        private function fly( e:Event ):void

                        {

                            //lets use our equations

                            var sx:Number = ux;       //distance moved in x dir

                            var vy:Number = uy + g    //new velocity in y dir

                            var sy:Number = uy + g/2  //distance moved in y dir

                            //apply to arrow

                            arrow.x += sx;

                            arrow.y += sy;

                            //save new y velocity

                            uy = vy;

                            //extra bonus rotation of arrow to point in the right direction

                            arrow.rotation = Math.atan2( uy, ux ) * 180 / Math.PI;

                        }

          }

}

Any help to get this working would be greatly appreciated.

Note: This is in an external class file (.as) and is linked to the document class.

This topic has been closed for replies.
Correct answer Ned Murphy

Get rid of the semicolon at the end of this line (5) and that might cure all of the errors...

        public class Arrow extends MovieClip;   <--- remove

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
April 19, 2013

Get rid of the semicolon at the end of this line (5) and that might cure all of the errors...

        public class Arrow extends MovieClip;   <--- remove