Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Parabola AS3

New Here ,
Apr 18, 2013 Apr 18, 2013

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.

TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 18, 2013 Apr 18, 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

Translate
LEGEND ,
Apr 18, 2013 Apr 18, 2013
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines