25 Replies Latest reply on Sep 30, 2009 4:59 AM by hitesh.rawat

    Stack overflow occurred

    hitesh.rawat Level 1

      HI,

       

      Error #1023: Stack overflow occurred

       

      This is a stange error i'm getting while running my app. I'm new to flex........ and the information i found regarding this error isn't that easy for me to understand...... or i'm not able to understand the whole point. I tried and made some changes to the code.....however not working......

       

      Some suggestions..........

       

      Thanks....

       

      H.R.

        • 1. Re: Stack overflow occurred
          hitesh.rawat Level 1

          This is the code of the action script part of the program.........

           

          __________________________________________________________________________

          package myapp
          {
             
              import flash.display.Loader;
              import flash.display.MovieClip;
              import flash.events.Event;
              import flash.net.URLLoader;
              import flash.net.URLRequest;
             
              import mx.controls.Alert;
              import mx.core.UIComponent;
                  
              
              
              
              
              public class Myclass extends main
              {
                 
                 
                   var loader:Loader = new Loader();   
                   var mc:MovieClip = new MovieClip();
                   var saving:String;
                   var uicomponent:UIComponent = new UIComponent();
                  
                  
                  
                  
                   public function settingSource(event:Event):void
                  {
                  
                 
                   panelChild.addChild(uicomponent);
                           
                 
                 
                  var XML_URL:String = "swf.xml";
                  var myXMLURL:URLRequest = new URLRequest(XML_URL);
                  var myLoader:URLLoader = new URLLoader(myXMLURL);
                  myLoader.addEventListener("complete", XMLSource);
               
               
                      
                  }
                      
                  
                   
                  
                  
                  
                  public function XMLSource(event:Event):void
                  {
                  
                   
                          var myXML:XML = new XML(event.target.data);
                          var IndexNumber ;
                          IndexNumber = optionList.selectedIndex;
                         
                         // T.visible = true;
                         // T.text = IndexNumber;
                         
                          if(IndexNumber == -1)
                          {
                             
                              playButton.label = "Play";
                             
                             
                        
                          }
                          else
                          {
                       
                           playButton.label = "Pause";
                           var req:URLRequest = new URLRequest(myXML.child(IndexNumber).attribute("source"));
                           loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingCompleted);
                               
                             loader.load(req);
                           uicomponent.addChild(loader);
                         
                          }
                 
                  }
                 
                 
                   public  function loadingCompleted(event:Event):void
                      {
                          
                          if(loader.content == null)
                          {
                             
                          (event.target.content as MovieClip).play();
                          
                           mc = event.target.content as MovieClip ;
                          
                          }
                          
                      }
                    
                      public  function onStop(event:Event):void
                      {
                     
                     Alert.show("Choose one from the list", "message");
                     
                     
                    
                     
                     
                      }   

           

              }
          }

          • 2. Re: Stack overflow occurred
            _Natasha_ Level 4

            Open it in debugger ang look what method is called.

             

            This class is extends main. I cann't see any cicles there.

            • 3. Re: Stack overflow occurred
              hitesh.rawat Level 1

              Well, it won't even load the page on the browser.

              I'm not invoking any methods of the action script code............so don't think it's because of that.....however i'll check it.

              • 4. Re: Stack overflow occurred
                _Natasha_ Level 4

                You don't call it manually, but many methods called during loading, initialization and other before showing.

                • 5. Re: Stack overflow occurred
                  hitesh.rawat Level 1

                  I'm running the application in Debug mode.............however there are so many variables....... which variable to look for which can cause this issue?

                  • 6. Re: Stack overflow occurred
                    hitesh.rawat Level 1

                    One more thing.......while running debug more..............it opens a action script file "FlexSprite.as"

                     

                    _______________________________________________________________

                    ////////////////////////////////////////////////////////////////////////////////
                    //
                    //  ADOBE SYSTEMS INCORPORATED
                    //  Copyright 2006 Adobe Systems Incorporated
                    //  All Rights Reserved.
                    //
                    //  NOTICE: Adobe permits you to use, modify, and distribute this file
                    //  in accordance with the terms of the license agreement accompanying it.
                    //
                    ////////////////////////////////////////////////////////////////////////////////

                     

                    package mx.core
                    {

                     

                    import flash.display.Sprite;
                    import mx.utils.NameUtil;

                     

                    /**
                    *  FlexSprite is a subclass of the Player's Sprite class
                    *  and the superclass of UIComponent.
                    *  It overrides the <code>toString()</code> method
                    *  to return a string indicating the location of the object
                    *  within the hierarchy of DisplayObjects in the application.
                    */
                    public class FlexSprite extends Sprite
                    {
                        include "../core/Version.as";

                     

                        //--------------------------------------------------------------------------
                        //
                        //  Constructor
                        //
                        //--------------------------------------------------------------------------

                     

                        /**
                         *  Constructor.
                         *
                         *  <p>Sets the <code>name</code> property to a string
                         *  returned by the <code>createUniqueName()</code>
                         *  method of the mx.utils.NameUtils class.</p>
                         *
                         *  <p>This string is the name of the object's class concatenated
                         *  with an integer that is unique within the application,
                         *  such as <code>"Button17"</code>.</p>
                         *
                         *  @see flash.display.DisplayObject#name
                         *  @see mx.utils.NameUtil#createUniqueName()
                         */
                        public function FlexSprite()
                        {
                            super();

                     

                            try
                            {
                                name = NameUtil.createUniqueName(this);
                            }
                            catch(e:Error)
                            {
                                // The name assignment above can cause the RTE
                                //   Error #2078: The name property of a Timeline-placed
                                //   object cannot be modified.
                                // if this class has been associated with an asset
                                // that was created in the Flash authoring tool.
                                // The only known case where this is a problem is when
                                // an asset has another asset PlaceObject'd onto it and
                                // both are embedded separately into a Flex application.
                                // In this case, we ignore the error and toString() will
                                // use the name assigned in the Flash authoring tool.
                            }
                        }

                     

                        //--------------------------------------------------------------------------
                        //
                        //  Overridden methods
                        //
                        //--------------------------------------------------------------------------

                     

                        /**
                         *  Returns a string indicating the location of this object
                         *  within the hierarchy of DisplayObjects in the Application.
                         *  This string, such as <code>"MyApp0.HBox5.Button17"</code>,
                         *  is built by the <code>displayObjectToString()</code> method
                         *  of the mx.utils.NameUtils class from the <code>name</code>
                         *  property of the object and its ancestors.
                         * 
                         *  @return A String indicating the location of this object
                         *  within the DisplayObject hierarchy.
                         *
                         *  @see flash.display.DisplayObject#name
                         *  @see mx.utils.NameUtil#displayObjectToString()
                         */
                        override public function toString():String
                        {
                            return NameUtil.displayObjectToString(this);
                        }
                    }

                     

                    }

                     

                     

                    Thanks

                    • 7. Re: Stack overflow occurred
                      _Natasha_ Level 4

                      In debug mode process stoped then exception occured.

                      Also there is a callStack in window "Debug". See in it and find repeated functions.

                      • 8. Re: Stack overflow occurred
                        hitesh.rawat Level 1

                        I didn't find callstack named variable..................

                        also i'm attaching the whole variable excel file .....plz check

                        • 9. Re: Stack overflow occurred
                          _Natasha_ Level 4

                          It's not a variable!!!

                           

                          There is a window caleed "Debug". There is a tree with processes. You need this tree!

                          • 10. Re: Stack overflow occurred
                            hitesh.rawat Level 1

                            found it..........

                             

                            myapp::Myclass   
                            main   

                             

                            is the process being repeated.

                             

                            For some 30-40 times

                            • 11. Re: Stack overflow occurred
                              _Natasha_ Level 4

                              Your should understand why it's called so many times.

                               

                              Or post code.

                              • 12. Re: Stack overflow occurred
                                hitesh.rawat Level 1

                                I tried finding the reason......however couldn't.

                                 

                                I'm pasting the code.

                                __________________________________________________________________________________________ ______________________________

                                 

                                <?xml version="1.0" encoding="utf-8"?>
                                <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"   horizontalAlign="left">
                                   
                                <mx:Script>
                                    <![CDATA[
                                       
                                        import myapp.Myclass;
                                       
                                        var abc:Myclass = new Myclass();
                                       
                                    ]]>
                                </mx:Script>
                                   

                                   

                                   
                                    
                                    <!-- Connecting XML -->
                                   
                                   
                                    <mx:XML id="swfList" source="swf.xml" xmlns=""/>
                                   
                                   
                                    <!-- The Swiff panel-->
                                   
                                    <mx:Panel layout="absolute" title="The Swiff Loader" id="loaderPanel" horizontalAlign="left" visible="true" right="10" bottom="10" left="405" top="52">
                                       
                                   
                                        <!-- Play Button -->
                                        <!--Stop Button-->
                                        <mx:Panel layout="absolute" id="panelChild" horizontalAlign="left" verticalAlign="top" visible="true" right="0" bottom="0" top="1" left="0">
                                            <mx:TextArea x="335" y="10" width="198" height="62" id="addComment" wordWrap="true" editable="true" enabled="true" visible="true" />
                                        </mx:Panel>
                                   
                                   
                                   
                                    </mx:Panel>
                                   
                                   
                                    <!--Text Area For Adding A Comment-->
                                   
                                   
                                    <!-- The Options List -->
                                    <mx:List x="36" y="166" height="181" id="optionList" dataProvider="{swfList.video}"
                                       
                                        labelField="@title"
                                       
                                        showDataTips="true"
                                        allowMultipleSelection="false"
                                       
                                       
                                       
                                         width="226"></mx:List>
                                        
                                    <mx:TextArea x="36" y="383" id="text1" wordWrap="true" maxChars="26" visible="false" />
                                   
                                    <mx:Label x="36" y="418" text="Add a Comment" width="160" fontWeight="bold" fontSize="12"/>
                                   
                                    <mx:List x="36" y="446" width="226" height="88"></mx:List>
                                   
                                    <mx:LinkButton x="36" y="468.4" label="Rectangle" width="226" id="rectangle"
                                         click=" addComment.visible = true" />
                                   
                                   
                                    <mx:LinkButton x="36" y="447" label="Circle" width="226" id="circle" />
                                   
                                    <mx:LinkButton x="36" y="490" label="Bubble" width="226" id="bubble"/>
                                   
                                    <mx:LinkButton x="36" y="512" label="Cloud" width="226" id="cloud"/>
                                   
                                    <mx:TextArea x="36" y="557" id="T" visible="false"/>
                                   
                                   
                                   
                                    <mx:Button x="175" y="708" label="Play" width="87" height="38" id="playButton" labelPlacement="left" enabled="true"
                                       
                                        click="abc.settingSource(event) " />
                                   
                                    <mx:Button x="298" y="708" label="Stop" width="75" height="38" id="stopButton" enabled="true"
                                       
                                        click="abc.onStop(event)"/>
                                       
                                   
                                       
                                    <mx:Button x="51" y="708" label="Save" id="save" width="87" height="38" click="abc.onSave(event)"    />
                                    <mx:Accordion x="36" y="542" width="226" height="158">
                                        <mx:Canvas label="Comment-1" width="100%" height="100%">
                                            <mx:Text x="0" y="0" width="224" height="136" id="commentTextbox" enabled="true" />
                                            <mx:LinkButton x="0" y="0" width="224" id="link"
                                                 height="138" click="" />
                                        </mx:Canvas>
                                    </mx:Accordion>
                                   
                                   
                                   
                                   

                                </mx:Application>

                                • 13. Re: Stack overflow occurred
                                  Flex harUI Adobe Employee

                                  If your application is in a file called main.mxml, then MyClass, which extends main, will instantiate another copy of the app which instantiates a MyClass which will instantiate the app...

                                   

                                  Alex Harui

                                  Flex SDK Developer

                                  Adobe Systems Inc.

                                  Blog: http://blogs.adobe.com/aharui

                                  • 14. Re: Stack overflow occurred
                                    hitesh.rawat Level 1

                                    well i have the same thing. My Myclass extends main.mxml. This may be the reason. How to fix it?

                                    • 15. Re: Stack overflow occurred
                                      Flex harUI Adobe Employee

                                      If your main application is called main.mxml and you have an ActionScript class MyClass that extends main.mxml, I don't understand why you would need to create an instance of MyClass in main.mxml.  That's circular and the cause of a stack overflow.

                                       

                                      Maybe list the files you are using and a brief description of what they are for and which ones extend others.

                                       

                                      Alex Harui

                                      Flex SDK Developer

                                      Adobe Systems Inc.

                                      Blog: http://blogs.adobe.com/aharui

                                      • 16. Re: Stack overflow occurred
                                        hitesh.rawat Level 1

                                        Flex harUI wrote:

                                         

                                        If your main application is called main.mxml and you have an ActionScript class MyClass that extends main.mxml, I don't understand why you would need to create an instance of MyClass in main.mxml.  That's circular and the cause of a stack overflow.

                                         

                                        Maybe list the files you are using and a brief description of what they are for and which ones extend others.

                                         

                                        Alex Harui

                                        Flex SDK Developer

                                        Adobe Systems Inc.

                                        Blog: http://blogs.adobe.com/aharui

                                        Apolozise for the late reply.

                                         

                                        However i want to ask, as i'm calling methods from the MYCLASS.AS and to access methods and variables of a class, i need to create a object of that class which why i did that.

                                        Also, as i'm using the MXML components in MYCLASS.AS that's why i need to extend the main.mxml class.

                                         

                                         

                                        Thanks

                                        • 17. Re: Stack overflow occurred
                                          hitesh.rawat Level 1

                                          Hi,

                                           

                                          How to break this loop??

                                           

                                          I need the AS file to extend MXML so that i can access the components and i need the class's instance to access the methods in the class. I don't know how to break this loop.

                                           

                                          Help needed.

                                          • 18. Re: Stack overflow occurred
                                            hitesh.rawat Level 1

                                            Anyone......!!!!!!!!!!!!

                                            • 19. Re: Stack overflow occurred
                                              _Natasha_ Level 4

                                              Read about

                                              Code Behind

                                              in Flex. It's what you need.

                                              1 person found this helpful
                                              • 20. Re: Stack overflow occurred
                                                hitesh.rawat Level 1

                                                Hi,

                                                 

                                                I read about Code Behind and try to rectify the issue endless loop.

                                                 

                                                Two things i want to ask............

                                                 

                                                First,

                                                 

                                                I'm getting error the prefix code "myapp" for element "myapp:Myclass" is not bound. Where myapp is the package and Myclass is the class.

                                                The only change i made in the MXML file was to extend myapp.

                                                 

                                                <?xml version="1.0" encoding="utf-8"?>
                                                <myapp:Myclass xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"   horizontalAlign="left" >
                                                   

                                                all the code


                                                </app:Myclass>

                                                 

                                                 

                                                Second

                                                 

                                                I read some where that Code Behind was removed from Action Script 3 because of creating conflict between different classes with same name. If its correct then can we use Code Behind here????

                                                 

                                                Thanks

                                                 

                                                H.R.

                                                • 21. Re: Stack overflow occurred
                                                  _Natasha_ Level 4

                                                  <myapp:Myclass xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"   horizontalAlign="left" xmlns:myapp="PATH_TO_CLASS">
                                                    

                                                  all the code


                                                  </myapp:Myclass>

                                                   

                                                  PATH_TO_CLASS you should set yours.

                                                  If your Myclass is in src/myCls/Myclass.mxml pth will be 'myCls.*'

                                                  • 22. Re: Stack overflow occurred
                                                    _Natasha_ Level 4

                                                    About second question.

                                                     

                                                    It's doesn't matter for you want it's recommended. As you designed your application - only using principles of Code Behind you can avoid loop in inheritance. You can name classes as you want to avoid conflicts.

                                                    • 23. Re: Stack overflow occurred
                                                      hitesh.rawat Level 1

                                                      I tried again and over came the error.

                                                       

                                                      Then in the action script class code............

                                                       

                                                      Myclass extends Application

                                                       

                                                      however it gives me error while coding like this.........because its not able to access the mxml file.

                                                       

                                                      so

                                                       

                                                      i tried again by extending the main.mxml

                                                       

                                                      Myclass extends main

                                                       

                                                      now its again giving me error stating

                                                       

                                                      D:\Work Space\tool\src\app\MyClass.as: Error: The definition is in circular inheritance.
                                                      D:\Work Space\tool\src\tool.mxml: Error: The definition is in circular inheritance.

                                                       

                                                      What to extend to access the mxml components???????

                                                      • 24. Re: Stack overflow occurred
                                                        _Natasha_ Level 4

                                                        http://learn.adobe.com/wiki/display/Flex/Code+Behind

                                                         

                                                        You should declare in AS class all variables you need from mxml as public. So you give an access to them.

                                                         

                                                        In mxml you instatiate this variables.

                                                         

                                                        And it's all.

                                                        1 person found this helpful
                                                        • 25. Re: Stack overflow occurred
                                                          hitesh.rawat Level 1

                                                          Yes, that was all.......

                                                           

                                                          Thanks... \,,,/