12 Replies Latest reply: Sep 6, 2012 9:02 AM by Ned Murphy RSS

    i need help please

    thunderxlight11111 Community Member

      hi , how are you guys ? i hope you all fine..

       

      here

      i have 2 problems the first one is why some sounds files  change after importing  it into flash

      and how can i fix that

       

      second problem is why flash asking me to add semicolon !! this is the first time and (i guess) it is because of static type , because i get this problem when i did that(trying to access variable from another class) also i couldn,t fix it after adding semicolon

      here are the 2 classes

       

       

      MAIN CLASS

       

      package
      {

      import flash.display.MovieClip;

      import flash.events.Event;

      import flash.events.KeyboardEvent;

          import flash.ui.Keyboard;
         import flash.media.Sound;


              import flash.media.SoundChannel;
      public class MAIN extends MovieClip
      {
        var LINKCONVERT:linkconvert = new linkconvert
        var checkpoint:Boolean
      var fireballindex:Array = new Array
      var ele:int
      var i:int = 0
      var FIREBIRD:firebird = new firebird
      var SCREAM:scream = new scream
      var SOUNDCHANNEL:SoundChannel = new SoundChannel
        public function MAIN()
        {

         addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
        

        }


        public function onAddedToStage(event:Event):void
        {

         addEventListener(Event.ENTER_FRAME,onEnterFrame);
          stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);
          FIREBIRD.stop()

        }

        public function onEnterFrame(event:Event)
        {
      FIREBIRD.x = hero.x
      FIREBIRD.y = hero.y
      if (hero.ELECTRICALSHIELD.stage){
      healthbar1.width -=1
      }

      if (bat1h != null){
      if (bat1h.stage){
      if (hero.ELECTRICALSHIELD.stage){
        if (hero.hitTestObject(bat1)){
        bat1h.width -= 5
       
        }
        }
      }


      }
      if (bat1 != null){
      if ( bat1h != null){
        if (bat1h.width == 0){
         removeChild(bat1h)
            removeChild(bat1)
                  removeChild(bat1b)
                  bat1b = null

            bat1 = null
            bat1h = null
           
           

        }
      }
      }

      if (bat1 != null){
      if (bat1.stage){
        if (hero.hitTestObject(bat1)){
         healthbar1.width -=  5
        }
      }
      }

         if (bat1 != null)
         {
          if (hero.ELECTRICALSHIELD.stage){

          if (hero.hitTestObject(bat1))
          {

           healthbar1.width -=  1;

       

          }
         }
         }
         if (healthbar1.width >= 80 && healthbar1.width <= 100)
         {
          zelda1.gotoAndPlay(1);

         }

         if (healthbar1.width >= 60 && healthbar1.width <= 80)
         {

          zelda1.gotoAndPlay(2);

         }

         if (healthbar1.width >= 40 && healthbar1.width <= 60)
         {

          zelda1.gotoAndPlay(3);

         }

         if (healthbar1.width >= 20 && healthbar1.width <= 40)
         {

          zelda1.gotoAndPlay(4);

         }

         if (healthbar1.width >= 0 && healthbar1.width <= 20)
         {

          zelda1.gotoAndPlay(5);

         }

       

       


        

         if (hero.hitTestObject(portal3))
         {
          if (bat1 != null)
          {

           var map4:BACKGROUND = new BACKGROUND  ;

           removeChild(bat1);
           bat1 = null;

           // this doesn't need to be done unless you added a listener outside the Bat1 classs

       

          }//normal

         }//normal
        }//func
         public function onKeyDown(event:KeyboardEvent):void {

       
                  if (event.keyCode == Keyboard.E)

                             {
               if (hero.visible){

        if(checkpoint){
         SOUNDCHANNEL = SCREAM.play()
                                      hero.visible = false
              addChild(FIREBIRD)
              }

      }
            if (!hero.visible){
      if(FIREBIRD.stage){
        if(!checkpoint){
         if(HERO.marioflying == false){
       
        SOUNDCHANNEL = LINKCONVERT.play()
                                      hero.visible = true
              removeChild(FIREBIRD)
              }
              }
      }
            }
            checkpoint = !checkpoint
      } //if event...


                             
         }//fun
      }//class

      }//pack

       

       

      HERO CLASS

       


      package


      {


              import flash.display.MovieClip;


              import flash.events.KeyboardEvent;


              import flash.ui.Keyboard;


              import flash.events.Event;


              import flash.sensors.Accelerometer;


              import flash.media.Sound;


              import flash.media.SoundChannel;


             


              public class HERO extends MovieClip


              {
      var MARIOHASFALLEN:mariohasfallen = new mariohasfallen;
      var static marioflying:Boolean = true;
      var vy:int
      var ROARING:roaring = new roaring
                      var NIGHTJUNGLE:nightjungle = new nightjungle
      var heromovesduringfirefly:Boolean

                      var ELECTRICALSHIELD:electricalshield = new electricalshield;


                      var fBall:fireball = new fireball();
      var fBalla:fireball = new fireball();
        var fBallb:fireball = new fireball();

      var fireshooting:Boolean = false
                     
      var lastpos:int


                      var FIREBALLSOUND:fireballsound = new fireballsound


                      var speed:int = 3;


                      var fireballindex:Array = new Array


                      var dir:int;


                      var ELECTRICITY:electricity = new electricity;


                      var SOUNDCHANNEL:SoundChannel = new SoundChannel


                      var firespeed:int = 10


                      var totalfirespeed = 0


                      var i:int


                      var fdir:int


                     


                      var fireballFlying:Boolean; // keep track of fireball


                     


                      public function HERO()


                      {


                             


                              addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);


                     


                      }


                     


                      public function onAddedToStage(event:Event):void


                      {


                             


                              addEventListener(Event.ENTER_FRAME, onEnterFrame);


                             
        
                              stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);


                             


                              stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);


                             

       


                              gotoAndStop(4);


               

                      }


                     


                      public function onEnterFrame(event:Event):void
        {

      if(visible){
      if(y <325){
        y += 10
       
        if(marioflying){
         SOUNDCHANNEL = MARIOHASFALLEN.play()
         marioflying = false
        }
       
        if(y>=325){
        y = 325
        marioflying = true
        }
      }
      }

      if(fBall.width > 55){
      fBall.width = 55
      }
      if(fBall.height > 55){
      fBall.height = 55
      }
                         


      y += vy


                              x += dir * speed


                             


                              if (fBall.stage)


                              {


                                      fBall.x += firespeed * fdir;


                                     


                                      fBall.width += 0


                                     


                                      fBall.height += 0


                                     


                                      totalfirespeed += 1


                                     


                              }


                              if (totalfirespeed == 20)


                                     


                              {


                                      if (fBall.stage)


                                      {


                                              MovieClip(parent).removeChild(fBall);


                                             


                                              totalfirespeed = 0;


                                             


                                              // fireball done flying

      fdir = dir
                                              fireballFlying = false;
               
                fireshooting = false;


                                      }


                                     


                              }


                     


                      }


                     


                      public function onKeyDown(event:KeyboardEvent):void


                      {


                             


                              if (event.keyCode == Keyboard.RIGHT)


                              {


                                      gotoAndStop(2);


                                     


                                      // is fireball flying?


                                      if (fireballFlying == false)
             
              {

                                               fdir = +1

      }

                                     


                                      dir = 1;


                                      speed = 10


                                      if (ELECTRICALSHIELD.stage)


                                              addChild(ELECTRICALSHIELD)
      if(MovieClip(parent).FIREBIRD.stage){
      speed =30
      }

                                   
      MovieClip(parent).FIREBIRD.gotoAndStop(2)


                              }


                             


                              if (event.keyCode == Keyboard.LEFT)


                              {

                                     

                                      gotoAndStop(1);

                                     

                                      // is fireball flying?

                                      if (fireballFlying == false)

                                      {

                                              fdir = -1

                                            
                                      }

                                   

                                      dir = -1;

                                      speed = 10

                                      if (ELECTRICALSHIELD.stage)

                                      {

                                              addChild(ELECTRICALSHIELD)

                                      }

                                 
      MovieClip(parent).FIREBIRD.gotoAndStop(1)
      if(MovieClip(parent).FIREBIRD.stage){
      speed =30
      }

                              }

                             

                              if (event.keyCode == Keyboard.UP)

                              {

                                     

                                     

                                     if (MovieClip(parent).FIREBIRD.stage)
      {
                                    
      vy = -30

      }
                                     

                              }
            if (event.keyCode == Keyboard.DOWN)

                              {
      if (MovieClip(parent).FIREBIRD.stage)
      {
                                    
              vy = 30
            

      }

            }

                              if (event.keyCode == Keyboard.Q)

                              {

                                      if(visible){

                                      speed = 30;

                                     

                                      addChild(ELECTRICALSHIELD);

                                      SOUNDCHANNEL = ELECTRICITY.play()

              }

                              }

                              if (event.keyCode == Keyboard.W)

                              {

                                      // tell myself a fireball is shot

                                      fireballFlying = true;


      if(!fireshooting){
      fireshooting = true
                                   

                                     

                                      fBall.name = "fb" + String(i);

                                      fBall.width = 25;
                 fBall.height = 25;

                                      fBall.x = x + 20

                                      fBall.y = y + 10
              
             
                                     

                                      fireballindex.push(fBall);
             
             
                if(this.visible == false){  
               if (MovieClip(parent).FIREBIRD.stage){
               fBall.width += 30
               fBall.height += 30
              SOUNDCHANNEL = ROARING.play()
              }
                }

                                     

                                      MovieClip(parent).addChild(fBall);
      if(this.visible == true){
      if (!MovieClip(parent).FIREBIRD.stage){
                                      SOUNDCHANNEL = FIREBALLSOUND.play()
             
      }}
        if(this.visible == false){

                                    SOUNDCHANNEL = ROARING.play()
      }
                                     

                                      i++;

                                     

                                      trace(i)

                                     

                                      trace(fBall.name)

                                     

                              }
            }
                             

                 

                      }

                     

                      public function onKeyUp(event:KeyboardEvent):void

                      {

                             

                              if (event.keyCode == Keyboard.Q)

                              {

                                     

                                      if (ELECTRICALSHIELD.stage)

                                      {

                                             

                                              removeChild(ELECTRICALSHIELD);

                                              if (SOUNDCHANNEL != null)

                                                      speed = 0;

                                              SOUNDCHANNEL = ELECTRICITY.play(1, 1)

                                             

                                      }

                                     

                              }

                              if (event.keyCode == Keyboard.W)

                              {

                                     

                              }

                             

                              if (event.keyCode == Keyboard.LEFT)

                              {

                                      speed = 0

                                      gotoAndStop(3);

                                      if (ELECTRICALSHIELD.stage)

                                              addChild(ELECTRICALSHIELD)

      MovieClip(parent).FIREBIRD.gotoAndStop(1)

                                     

                              }

                               if (event.keyCode == Keyboard.RIGHT)

                              {

                                      speed = 0

                                      gotoAndStop(4);

                                      if (ELECTRICALSHIELD.stage){

                                              addChild(ELECTRICALSHIELD)
              }
                
      MovieClip(parent).FIREBIRD.gotoAndStop(2)

      }
      if (event.keyCode == Keyboard.UP)

                              {
             vy = 0
            }
            if (event.keyCode == Keyboard.DOWN)

                              {
             vy = 0
            }
          }
         //لا اله الا الله
          // there is no god except 1 god
          }
      }

      and here is the error message

       

      C:\Users\Owner n\Desktop\project (4) \HERO.as, Line 39 1086: Syntax error: expecting semicolon before marioflying.

       

       

      thank you guys for all the help in all my threads