19 Replies Latest reply on Oct 28, 2007 10:03 AM by kglad

    Flash AS3 error codes

    easypzmaths
      Does anyone know how I can find the meanings of the Flash AS3 error codes?
        • 1. Re: Flash AS3 error codes
          mgoodes
          In AS3 help, look inside:
          ActionScript 3.0 Language and Components Reference/Appendixes
          • 3. Re: Flash AS3 error codes
            easypzmaths Level 1
            Thank you for pointing me in the right direction.

            Unfortunately, the information there is almost useless . It says "Call to a possibly undefined method _"
            This refers to a line in an AS file that starts
            package {

            With such a lot of possible causes they should aim to give us some examples to cross off.
            Where to next I wonder???????????????
            • 4. Re: Flash AS3 error codes
              mgoodes Level 1
              I just solved a similar problem for myself. If you give us more information maybe we can help.
              • 5. Re: Flash AS3 error codes
                kglad Adobe Community Professional & MVP
                if there's anything after the left brace on that line you either have a problem or unusual formatting.
                • 6. Re: Flash AS3 error codes
                  easypzmaths Level 1
                  Thank you for your response. In the same directory as DrawingShapes2.fla, using strict mode, I have a DrawingShapes2.as file. In publish settings/Flash tab/settings/Document class I have DrawingShapes2. When I click the green tick it says the class was found okay. I have set the classpath to the current directory. The AS file has the matching (, ), {, and } for constructor and listeners. Puzzled!
                  package {

                  import flash.display.Sprite;
                  import flash.events.MouseEvent;

                  public class DrawingShapes2 extends Sprite {
                  var sp:Sprite = new Sprite();
                  public function DrawingShapes2 ():void {
                  sp.graphics.lineStyle(2,0x000000);

                  Later...
                  function mouseDown(event:MouseEvent):void {
                  sp.startDrag();
                  Sprite(event.target).alpha=0.25;
                  }
                  }// end of class
                  }// end of package
                  • 7. Re: Flash AS3 error codes
                    easypzmaths Level 1
                    Even this empty code causes "Call to a possibly undefined method _"
                    package
                    {
                    import flash.display.Sprite;

                    public class DrawingShapes2 extends Sprite {
                    public function DrawingShapes2 ():void {
                    }// contructor
                    }// class
                    }// package
                    • 8. Re: Flash AS3 error codes
                      kglad Adobe Community Professional & MVP
                      neither of those code snippets contain a coding error. copy the error message and paste it to this forum.
                      • 9. Re: Flash AS3 error codes
                        easypzmaths Level 1
                        kglad and mgoodes, thank you for your time.
                        I eventually found a solution, but not a reason, at...
                        http://www.actionscript.org/forums/archive/index.php3/t-141256.html

                        Once I removed the name DrawingShapes2 in publish settings/Flash tab/settings/Document class it compiled okay. It seems to be that such a named class has to extend a particular display object (not checked yet).

                        Many thanks.
                        • 10. Re: Flash AS3 error codes
                          kglad Adobe Community Professional & MVP
                          it needs to extend the Spite or MovieClip class. that's not the problem.
                          • 11. Flash AS3 error codes
                            easypzmaths Level 1
                            The code is from ActionSciprt 3.0 - by Gary Rosenzweig but is has moved from the fla to an AS file. It was working fine. It has been changed and it isn't working now (yet to find out why). If I set DrawingShapes2 as the Document class it won't compile.
                            package
                            {
                            import flash.display.Sprite;
                            import flash.events.MouseEvent;

                            public class DrawingShapes2 extends Sprite {
                            var sp:Sprite = new Sprite();

                            public function DrawingShapes2 ():void {
                            sp.graphics.lineStyle(2,0x000000);
                            sp.graphics.moveTo(100,200);
                            sp.graphics.lineTo(150,250);

                            // create a curve and then another line
                            sp.graphics.curveTo(200,300,250,250);
                            sp.graphics.lineTo(300,200);

                            // draw two rectangles
                            sp.graphics.drawRect(50,50,300,250);
                            sp.graphics.drawRoundRect(40,40,320,270,25,25);

                            // circle and ellipse
                            sp.graphics.drawCircle(150,100,20);
                            sp.graphics.drawEllipse(180,150,40,70);

                            // draw a filled circle
                            sp.graphics.beginFill(0x333333);
                            sp.graphics.drawCircle(250,100,20);
                            sp.graphics.endFill();

                            sp.addEventListener(MouseEvent.MOUSE_DOWN, mouseisDown);
                            sp.buttonMode = true;
                            sp.useHandCursor=true;

                            sp.addEventListener(MouseEvent.MOUSE_UP, mouseReleased);

                            addChild(sp);
                            }// contructor

                            function mouseisDown(event:MouseEvent):void {
                            sp.startDrag();
                            Sprite(event.target).alpha=0.25;
                            }
                            function mouseReleased(event:MouseEvent):void {
                            sp.stopDrag();
                            Sprite(event.target).alpha=1;
                            }
                            }
                            }
                            • 12. Re: Flash AS3 error codes
                              kglad Adobe Community Professional & MVP
                              if that class extended MovieClip, you would have no problem. (don't forget to import the Sprite class.)
                              • 13. Re: Flash AS3 error codes
                                easypzmaths Level 1
                                The only code in the fla is on the first frame...

                                import DrawingShapes2;
                                var ds:DrawingShapes2 = new DrawingShapes2();
                                addChild(ds);

                                This now works but I also need addChild(sp) in the constructor - don't know why.
                                Also, I am still puzzled as to why the Document Class affects it.
                                • 14. Re: Flash AS3 error codes
                                  kglad Adobe Community Professional & MVP
                                  you don't need any code in your fla if DrawingShapes2 is your document class.
                                  • 15. Flash AS3 error codes
                                    easypzmaths Level 1
                                    Fascinating!
                                    I set DrawingShapes2 as the document class and removed the 3 lines of code from the fla but I still got the "Call to a possibly undefined method addFrameScript". At this point my fla had an empty actionscript frame. Once I deleted the frame the error went. When I added a new frame and typed a couple of spaces the error returned when I published it. Previously I had some commented out code which also caused the error. I looked at Mooock's Essential Actionscript Document Class description (page 828) and searched for the undocumented addFrameScript function. It seems that the cause is as follows...

                                    "Automatically declare stage instances" creates named variables for library clips on stage that were not declared by the coder. An empty code frame (even though it's only empty space) is considered a MovieClip and gets declared automatically, and then the system tries to call the undocumented addFrameScript() on non existent code. If I extend my AS class from MovieClip rather than Sprite it probably fixes that.

                                    kglad, Thank you for helping me along that interesting journey.
                                    • 16. Re: Flash AS3 error codes
                                      kglad Adobe Community Professional & MVP
                                      you're welcome. and your last sentence is correct. and, i believe, if you add an extra frame to your movieclip but do not add any code/spaces to the actions panel and there's nothing on-stage in that additional frame, you can still use a sprite class as the document class.
                                      • 17. Re: Flash AS3 error codes
                                        mgoodes Level 1
                                        Great discussion! There was one point that was left unanswered:
                                        "This now works but I also need addChild(sp) in the constructor - don't know why.
                                        Also, I am still puzzled as to why the Document Class affects it."

                                        It looks like your class DrawingShapes2 is creating a container within a container. In your first statement you have:

                                        var sp:Sprite = new Sprite();

                                        This creates a sprite container within DrawingShapes2 and you do all your drawing to that container. Of course sp then needs to be added to the stage by the addChild(sp) statement because at that point you've only added its parent to the stage (via your frame code).

                                        As an experiment, if you're interested, you could try this in place of the above statement:
                                        var sp:Sprite = this;
                                        Then you'll have to remove the addChild(sp) statement because it is no longer a container within a container.

                                        Or, instead, you could change your frame code from:
                                        addChild(ds);
                                        to:
                                        addChild(ds.sp);
                                        and then you would need to remove the addChild(sp) statement in your constructor.

                                        I've found it's hard to mix frame code if you have a Document Class. There appear to be all kinds of rules and restrictions. It seems to be much easier to have no frame code or to have no Document Class and to use your frame code to instantiate your class the same way we did in older versions of AS.

                                        If you try any of this let us know. These discussions are a great way to learn more.


                                        • 18. Re: Flash AS3 error codes
                                          easypzmaths Level 1
                                          Timeout!
                                          I replaced sp:Sprite = new Sprite();
                                          with var sp:Sprite = this;
                                          and removed addChild(sp);
                                          as suggested but it didn't work.

                                          I think it's because "this" is referring to the class, not an instantiated object of the class.
                                          This throws some light on the topic but I still haven't got it sorted...
                                          http://www.kirupa.com/forum/showthread.php?p=2129548#post2129548


                                          • 19. Re: Flash AS3 error codes
                                            kglad Adobe Community Professional & MVP
                                            what's the problem?