25 Replies Latest reply: Aug 28, 2012 11:56 AM by sinious RSS

    error #1069

    thunderxlight11111 Community Member

      hi

       

      i get this error after doing some change in the hero class , i mean after this command

       

      MovieClip(parent) only!.

       

      the old code (works very well)

       

      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 NIGHTJUNGLE:nightjungle = new nightjungle
              var ELECTRICALSHIELD:electricalshield=new electricalshield  ;
      var fBall:fireball = new fireball();

      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
              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);

                 
      SOUNDCHANNEL = NIGHTJUNGLE.play(1,1000)
                  gotoAndStop(4);
        

              }

       

              public function onEnterFrame(event:Event):void {
        x += dir * speed
         if (fBall.stage){
         fBall.x += firespeed * dir;
         fBall.width +=2
         fBall.height += 2
         totalfirespeed +=1
        
         }
         if (totalfirespeed == 10){
          removeChild(fBall)
          totalfirespeed = 0
         
         
         }
        
              }

              public function onKeyDown(event:KeyboardEvent):void {

                  if (event.keyCode==Keyboard.RIGHT) {

                      gotoAndStop(2);

                      dir=1;
          speed = 10
          if (ELECTRICALSHIELD.stage)
          addChild(ELECTRICALSHIELD)
         

                  }


                  if (event.keyCode==Keyboard.LEFT) {

                      gotoAndStop(1);


                      dir=-1;
          speed  = 10
          if (ELECTRICALSHIELD.stage)
          addChild(ELECTRICALSHIELD)

                  }

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

                      gotoAndStop(1);

                      y=10;

                  }

                  if (event.keyCode==Keyboard.Q) {

                      speed=30;

                      addChild(ELECTRICALSHIELD);
          SOUNDCHANNEL = ELECTRICITY.play()
         
                  }
      if (event.keyCode == Keyboard.W) {

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

      fBall.width = 50;
      fBall.x



      fireballindex.push(fBall);


      addChild(fBall);
      SOUNDCHANNEL = FIREBALLSOUND.play()

      i++;
      trace(i)
      trace( fBall.name)

         }
        if (event.keyCode == Keyboard.E) {
      MovieClip(parent).aa.x = x +100
        }
      }

              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)

                  } else if (event.keyCode == Keyboard.RIGHT) {
      speed =0
                      gotoAndStop(4);
      if (ELECTRICALSHIELD.stage)
          addChild(ELECTRICALSHIELD)
                  }

              }

          }

      }

       

       

       

       

       

      new code (which is the one who has the error message)

       

      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 NIGHTJUNGLE:nightjungle = new nightjungle
              var ELECTRICALSHIELD:electricalshield=new electricalshield  ;
      var fBall:fireball = new fireball();

      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
              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);

                 
      SOUNDCHANNEL = NIGHTJUNGLE.play(1,1000)
                  gotoAndStop(4);
        

              }

       

              public function onEnterFrame(event:Event):void {
        x += dir * speed
         if (MovieClip(parent).fBall.stage){
         MovieClip(parent).fBall.x += firespeed * dir;
         MovieClip(parent).fBall.width +=2
         MovieClip(parent).fBall.height += 2
         totalfirespeed +=1
        
         }
         if (totalfirespeed == 10){
          MovieClip(parent).removeChild(fBall)
          totalfirespeed = 0
         
         
         }
        
              }

              public function onKeyDown(event:KeyboardEvent):void {

                  if (event.keyCode==Keyboard.RIGHT) {

                      gotoAndStop(2);

                      dir=1;
          speed = 10
          if (ELECTRICALSHIELD.stage)
          addChild(ELECTRICALSHIELD)
         

                  }


                  if (event.keyCode==Keyboard.LEFT) {

                      gotoAndStop(1);


                      dir=-1;
          speed  = 10
          if (ELECTRICALSHIELD.stage)
          addChild(ELECTRICALSHIELD)

                  }

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

                      gotoAndStop(1);

                      y=10;

                  }

                  if (event.keyCode==Keyboard.Q) {

                      speed=30;

                      addChild(ELECTRICALSHIELD);
          SOUNDCHANNEL = ELECTRICITY.play()
         
                  }
      if (event.keyCode == Keyboard.W) {

      SOUNDCHANNEL = FIREBALLSOUND.play()
          MovieClip(parent).fBall.name = "fb"+String(i);

      MovieClip(parent).fBall.width = 20;
      MovieClip(parent).fBall.x =400
      MovieClip(parent).fBall.y = 400



      fireballindex.push(MovieClip(parent).fBall);


      MovieClip(parent).addChild(fBall);
      SOUNDCHANNEL = FIREBALLSOUND.play()

      i++;
      trace(i)
      trace( MovieClip(parent).fBall.name)

         }
        if (event.keyCode == Keyboard.E) {
      MovieClip(parent).aa.x = x +100
        }
      }

              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)

                  } else if (event.keyCode == Keyboard.RIGHT) {
      speed =0
                      gotoAndStop(4);
      if (ELECTRICALSHIELD.stage)
          addChild(ELECTRICALSHIELD)
                  }

              }

          }

      }

       

      thank you

        • 1. Re: error #1069
          Ned Murphy CommunityMVP

          You should always include the entire error message(s) in your postings.  With a few exceptions, there are only a couple of errors that I remember what they involve without having to see the message. 

           

          Be sure you have enabled the Permit Debugging option in your Flash Publish Settings before testing again to get the message.  It can help by isolating the line where the problem is.

           

          Also, you can then help others to help you by highlighting where in all the code you show the problemed code is.

          • 2. Re: error #1069
            thunderxlight11111 Community Member

            lol , sorry i forget that

            here

            ReferenceError: Error #1069: Property fBall not found on MAIN and there is no default value.

            at HERO/onEnterFrame()

            • 3. Re: error #1069
              thunderxlight11111 Community Member

              sorry i forgot that  "permit debugging"

               

              here

              the message after the new debug

               

              ReferenceError: Error #1069: Property fBall not found on MAIN and there is no default value.

              at HERO/onEnterFrame()[C:\Users\Owner n\Desktop\project (4) \HERO.as:56]

              • 4. Re: error #1069
                sinious Community Member

                You're adding an ADDED_TO_STAGE and an ENTER_FRAME event one after another. The ENTER_FRAME event is checking fBall.stage. At that point you probably have not even added fBall to the stage yet. You should check to see if it exists in your onEnterFrame() method.

                 

                e.g.

                 

                public function onEnterFrame(event:Event):void

                {

                    if (!fBall) { return; } // no fBall exists, ignore

                 

                    x += dir * speed

                    if (fBall.stage)

                    {

                        fBall.x += firespeed * dir;

                        fBall.width += 2

                        fBall.height += 2

                        totalfirespeed += 1

                 

                    }

                    if (totalfirespeed == 10)

                    {

                        removeChild(fBall)

                        totalfirespeed = 0

                 

                    }

                }

                • 5. Re: error #1069
                  thunderxlight11111 Community Member

                  no , the problem  from the other code with  MovieClip(parent) function

                   

                  thank you for your replay

                  • 6. Re: error #1069
                    Ned Murphy CommunityMVP

                    Please highlight line 56 in your code, either bold it or even better make it appear a different color.

                    • 7. Re: error #1069
                      sinious Community Member

                      Line 56 when I copy your code is exactly what I posted, "if (fBall.stage){". You're checking a property (stage) of something that has not been added to the display list and therefore has no stage property. Please try adding the code I bolded (the easy way) or only add an ENTER_FRAME handler once it has been added to the display list (the better way to reduce wasted cycles).

                      • 8. Re: error #1069
                        thunderxlight11111 Community Member

                        sorry , i will edit it now

                        • 9. Re: error #1069
                          thunderxlight11111 Community Member

                          i dont know why i cant edit it now

                          but here

                           

                           

                          54 public function onEnterFrame(event:Event):void {

                          55

                             56 if (MovieClip(parent).fBall.stage){   

                            57 MovieClip(parent).fBall.x += firespeed * dir;

                            58 MovieClip(parent).fBall.width +=2

                            59 MovieClip(parent).fBall.height += 2

                            60 totalfirespeed +=1

                          thank you for your replay

                          • 10. Re: error #1069
                            thunderxlight11111 Community Member

                            no that is the old code

                             

                            the problem came after this

                             

                            if (MovieClip(parent).fBall.stage){

                             

                            because i dont want fball to be a child for the hero class anymore then i get this error after change all the fBall to MovieClip(parent).fBall

                             

                            thank you for your replay

                            • 11. Re: error #1069
                              sinious Community Member

                              Ah didn't see it was 2 different pastes of code but the issue is the same. Here:

                              public function onEnterFrame(event:Event):void

                              {

                                   if (!MovieClip(this.parent).fBall) { return; } // doesn't exist yet

                                   x += dir * speed

                                   if (MovieClip(parent).fBall.stage)

                                   {

                                        MovieClip(parent).fBall.x += firespeed * dir;

                                        MovieClip(parent).fBall.width += 2

                                        MovieClip(parent).fBall.height += 2

                                        totalfirespeed += 1

                                       

                                   }

                                   if (totalfirespeed == 10)

                                   {

                                        MovieClip(parent).removeChild(fBall)

                                        totalfirespeed = 0

                                       

                                   }

                              }

                              • 12. Re: error #1069
                                thunderxlight11111 Community Member

                                i copied your code  in on enter frame function , but the problem still the same ?

                                 

                                thank you for your replay

                                • 13. Re: error #1069
                                  sinious Community Member

                                  So it exists but it's not on the display list. You'll need to amend that line of code to check if it's on a display list:

                                   

                                  if ((!MovieClip(this.parent).fBall) || (!MovieClip(this.parent).contains(MovieClip(this.parent).fBall))) { return; }

                                   

                                  Again it needs to not only exist but actually be on the display list. I should have remembered that

                                   

                                  Optionally you can just check to see if the stage property is null, same difference. e.g.: MovieClip(this.parent).fBall.stage == null.

                                  • 14. Re: error #1069
                                    thunderxlight11111 Community Member

                                    sorry but iam not realy sure if i realy understand what you mean,

                                    i did this

                                    remove this line

                                    if (!MovieClip(this.parent).fBall) { return; }

                                     

                                    then i add this line

                                    if ((!MovieClip(this.parent).fBall) || (!MovieClip(this.parent).contains(MovieClip(this.parent).fBall))) { return; }

                                     

                                    but the problem still there ?

                                     

                                    sorry because  dont get what you mean

                                    thank you again for your replay

                                    • 15. Re: error #1069
                                      sinious Community Member

                                      Can you paste the whole code block including what you inserted? It must be at the beginning of the function.

                                       

                                      All the code is doing is quickly checking 2 things. 1, if fBall exists. 2, if it's currently on the display list.

                                       

                                      If it doesn't exist you'll get one error. If it exists but it's not on the display list then the "stage" property won't be valid and you'll get a different error.

                                       

                                      Include the error you're getting as well please.

                                      • 16. Re: error #1069
                                        thunderxlight11111 Community Member

                                        here


                                        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 NIGHTJUNGLE:nightjungle = new nightjungle
                                                var ELECTRICALSHIELD:electricalshield=new electricalshield  ;
                                        var fBall:fireball = new fireball();

                                        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
                                                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);

                                                   
                                        SOUNDCHANNEL = NIGHTJUNGLE.play(1,1000)
                                                    gotoAndStop(4);
                                          

                                                }

                                         

                                              public function onEnterFrame(event:Event):void
                                        {
                                        if ((!MovieClip(this.parent).fBall) || (!MovieClip(this.parent).contains(MovieClip(this.parent).fBall))) { return; }

                                             x += dir * speed
                                             if (MovieClip(parent).fBall.stage)
                                             {
                                                  MovieClip(parent).fBall.x += firespeed * dir;
                                                  MovieClip(parent).fBall.width += 2
                                                  MovieClip(parent).fBall.height += 2
                                                  totalfirespeed += 1
                                                 
                                             }
                                             if (totalfirespeed == 10)
                                             {
                                                  MovieClip(parent).removeChild(fBall)
                                                  totalfirespeed = 0
                                                 
                                             }
                                        }

                                                public function onKeyDown(event:KeyboardEvent):void {

                                                    if (event.keyCode==Keyboard.RIGHT) {

                                                        gotoAndStop(2);

                                                        dir=1;
                                            speed = 10
                                            if (ELECTRICALSHIELD.stage)
                                            addChild(ELECTRICALSHIELD)
                                           

                                                    }


                                                    if (event.keyCode==Keyboard.LEFT) {

                                                        gotoAndStop(1);


                                                        dir=-1;
                                            speed  = 10
                                            if (ELECTRICALSHIELD.stage)
                                            addChild(ELECTRICALSHIELD)

                                                    }

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

                                                        gotoAndStop(1);

                                                        y=10;

                                                    }

                                                    if (event.keyCode==Keyboard.Q) {

                                                        speed=30;

                                                        addChild(ELECTRICALSHIELD);
                                            SOUNDCHANNEL = ELECTRICITY.play()
                                           
                                                    }
                                        if (event.keyCode == Keyboard.W) {

                                        SOUNDCHANNEL = FIREBALLSOUND.play()
                                            MovieClip(parent).fBall.name = "fb"+String(i);

                                        MovieClip(parent).fBall.width = 20;
                                        MovieClip(parent).fBall.x =400
                                        MovieClip(parent).fBall.y = 400

                                         

                                        fireballindex.push(MovieClip(parent).fBall);


                                        MovieClip(parent).addChild(fBall);
                                        SOUNDCHANNEL = FIREBALLSOUND.play()

                                        i++;
                                        trace(i)
                                        trace( MovieClip(parent).fBall.name)

                                           }
                                          if (event.keyCode == Keyboard.E) {
                                        MovieClip(parent).aa.x = x +100
                                          }
                                        }

                                                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)

                                                    } else if (event.keyCode == Keyboard.RIGHT) {
                                        speed =0
                                                        gotoAndStop(4);
                                        if (ELECTRICALSHIELD.stage)
                                            addChild(ELECTRICALSHIELD)
                                                    }

                                                }

                                            }

                                        }

                                         

                                         

                                        message error

                                         

                                        ReferenceError: Error #1069: Property fBall not found on MAIN and there is no default value.

                                        at HERO/onEnterFrame()[C:\Users\Owner n\Desktop\project (4) \HERO.as:57]

                                        • 17. Re: error #1069
                                          sinious Community Member

                                          I'm assuming you have a class that is loading this "HERO" class inside itself because you're trying to access MovieClip(parent). I see you're adding fBall to the parent when the user presses the "W" key. I presumed the parent would have a defined object you're accessing via MovieClip(fBall) when I should have just read all of the code.

                                           

                                          You have a direct reference to fBall inside this class that fires off onEnterFrame. You can't reference it via MovieClip(parent).fBall as if it's a direct object reference because it's not. And if you were to try to access it as a MovieClip then you'd need to use a getChild* function of MovieClip(parent) to gain access to it via index or name. But you don't need to do that.

                                           

                                          Your first class had it correct. Just access fBall directly like this:

                                           

                                          public function onEnterFrame(event:Event):void

                                          {

                                              if ((!fBall) || (!MovieClip(this.parent).contains(fBall))) { return; }

                                           

                                              x += dir * speed

                                           

                                              fBall.x += firespeed * dir;

                                              fBall.width += 2

                                              fBall.height += 2

                                           

                                              totalfirespeed += 1

                                           

                                              if (totalfirespeed == 10)

                                              {

                                                  MovieClip(parent).removeChild(fBall)

                                                  totalfirespeed = 0

                                           

                                              }

                                          }

                                           

                                          edit:

                                           

                                          In the future you only need to paste the relevant lines of code giving you an error, plus a few lines above and below it. If you need to paste a large amount of code it's advisable to use something that makes code easy to see like:

                                          http://pastebin.com/

                                          • 18. Re: error #1069
                                            thunderxlight11111 Community Member

                                            i did that , but now i cant move the player or use w spell

                                             

                                            i get this error

                                            ReferenceError: Error #1069: Property fBall not found on MAIN and there is no default value.

                                            at HERO/onKeyDown()[C:\Users\Owner n\Desktop\project (4) \HERO.as:135]

                                            after pressing W but there are no errors when i enter the frame except that i cant move the player

                                             

                                            maybe because this command doesn,t work

                                            x += dir * speed // in on enter frame function

                                             

                                            yeah right (maybe you know that already) this class not document class it is the hero class

                                            i can fix the error in the main class but i want to learn how to do that with normal class 

                                             

                                            thank you for your replay

                                            • 19. Re: error #1069
                                              sinious Community Member

                                              You have to remove any MovieClip(parent).fBall references overall. Use fBall directly as I've shown you above. I'll show you how your W key code would look rewritten with it:

                                               

                                              if (event.keyCode == Keyboard.W)

                                              {

                                                  SOUNDCHANNEL = FIREBALLSOUND.play()

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

                                               

                                                  fBall.width = 20;

                                                  fBall.x = 400

                                                  fBall.y = 400

                                               

                                                  fireballindex.push(fBall);

                                               

                                                  MovieClip(parent).addChild(fBall);

                                                  SOUNDCHANNEL = FIREBALLSOUND.play()

                                               

                                                  i++;

                                                  trace(i)

                                                  trace(fBall.name)

                                              }

                                               

                                              Remove the MovieClip(parent) off of any references to fBall in all your code. That class can directly access fBall. Even though you're adding it to the parent display list you still access it in the class directly using fBall. The class still owns the object.

                                               

                                              The HERO class extends MovieClip so you don't need to add it to the parent at all. I'm assuming you have a reason for doing so. Adding it to the HERO display list would make it show up as long as HERO was on the parents display list. Although the position of the object would be relative to the position of the HERO.

                                              • 20. Re: error #1069
                                                thunderxlight11111 Community Member

                                                ohhh , lol yeah i get it now , it was stupid thing but i didn,t notice i

                                                thank you again for your help

                                                just there is one problem left the object doesn,t display after clicking  W there is no errors and the object effects work very well

                                                i just cant see it

                                                i will try to fix this  problem

                                                thank you again for your help

                                                • 21. Re: error #1069
                                                  thunderxlight11111 Community Member

                                                  thank you dr.murphy

                                                   

                                                  that Permit Debugging is realy helpful

                                                  • 22. Re: error #1069
                                                    sinious Community Member

                                                    When you add the fBall you still want to add it to the parent. While removing MovieClip(parent) from fBall, you didn't remove the MovieClip(parent) when you were adding it to the parents display list did you? Like in the code I posted above I'm still adding the fBall to the parent via:

                                                     

                                                    MovieClip(parent).addChild(fBall);

                                                     

                                                    So if you did a global find/replace and removed MovieClip(parent) then it might look like:

                                                     

                                                    addChild(fBall);

                                                     

                                                    If your HERO class isn't on the display list then you won't see the fireball anymore so make sure you still have MovieClip(parent) on that line.

                                                    • 23. Re: error #1069
                                                      Ned Murphy CommunityMVP

                                                      You're welcome

                                                      • 24. Re: error #1069
                                                        thunderxlight11111 Community Member

                                                        i fixed it

                                                        it was here

                                                        MovieClip(parent).fBall.x =4000!! 

                                                        thank you for your help

                                                        • 25. Re: error #1069
                                                          sinious Community Member

                                                          You're welcome and good luck!