15 Replies Latest reply on Sep 15, 2009 3:03 AM by hitesh.rawat

    Error #1009

    hitesh.rawat Level 1

      HI,

       

      I made a simple function to play and stop a particular swf.I have also posted the code for it. This code works fine and won't give any compile time error.........but while running it.........it does give error #1009 however not with all the SWF files i link it to.

       

      I mean firstly when i coded, i used a .SWF file........but after that i used another .SWF.......for which code gave this error...............so I'm confused how can replacing the files can induce errors?????????

       

       

      Thanks

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()" >

       

       

       

      <mx:Script>
          <![CDATA[
              import flash.display.Loader;
              import mx.core.UIComponent;
            
           
           var mc;
               
           private function onCreationComplete():void
                  {
                      var uicomponent:UIComponent = new UIComponent();
                      addChild(uicomponent);
                     
                     
                     
                     
                      uicomponent.x = 303;
                      uicomponent.y = 55;
                      uicomponent.width = 404;
                       
                      var loader:Loader = new Loader();
                      var req:URLRequest = new URLRequest("slide7.swf");

       


                      loader.load(req);
                      uicomponent.addChild(loader);
                     
                      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingCompleted);
                     
                    
                     
                    
                  }
                
                  private function loadingCompleted(event:Event):void
                  {
                      
                      (event.target.content as MovieClip).play();
                       mc = event.target.content ;
                      
                      
                  }
        
        
        
         private function onStop():void
         {
        
        
        
         mc.stop();
        
        
         }
        
        
        
          ]]>
      </mx:Script>

       

       

       

       

       

          <mx:LinkButton x="130" y="455" label="Play" id="play" click="onCreationComplete()"/>
        
          <mx:LinkButton x="43" y="455" label="stop" id="stop" click="onStop()"/>
          <mx:TextArea x="21" y="433" visible="false" id="T"/>
          
        
       
      </mx:Application>

        • 1. Re: Error #1009
          hitesh.rawat Level 1

          anyone.....plzz.......

          • 2. Re: Error #1009
            _Natasha_ Level 4

            Hi,

             

            can you post all error message? There is an info about function and string where is a error.

             

            When do you get this error?

             

            The only thing I see that it's not a good:

            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingCompleted);

            should be called before loader.load(req)

            • 3. Re: Error #1009
              hitesh.rawat Level 1

              I did what you suggested........

               

              loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingCompleted);

              should be called before loader.load(req)

               

               

              however yesterday when i left.......it was giving error # 1009......and today when i started again..........it gave me error # 1034.

               

               

               

              TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@53b7079 to flash.net.URLRequest.
                  at main/settingSource()[D:\Work Space\Copy of\src\main.mxml:27]
                  at main/__playButton_click()[D:\Work Space\Copy of\src\main.mxml:105]

               

              The code is same as posted above ..... no changes made....othen than mentioned here.

               

              Thanks

              • 4. Re: Error #1009
                hitesh.rawat Level 1

                its gives me the error where i'm checking the path of the files it is fetching.........

                 

                 

                 

                var req:URLRequest = myXML.child(IndexNumber).attribute("source");

                 

                 

                thanks

                • 5. Re: Error #1009
                  hitesh.rawat Level 1

                  I tried checking if it is returning the correct selected index.................

                   

                  T.text = IndexNumber;

                   

                  and it worked......it was showing the correct index number..............

                   

                  What i think is that.....the issue is with

                   

                  myXML.child(IndexNumber).attribute("source");

                   

                  that it is not returning the correct path.

                   

                  thanks

                  • 6. Re: Error #1009
                    _Natasha_ Level 4

                    XML type have only one method child.

                    child(propertyName:Object):XMLList

                     

                    So if you call myXML.child(childNumber) you got nothing.

                     

                    Alos you should understand that the result is XMLList!

                    • 7. Re: Error #1009
                      hitesh.rawat Level 1

                      I'm sorry i didn't actually get this. Also i used this same statement in another program.....where it worked fine and got me the path.......when i was working using swfloader instead of the movieclip.

                      • 8. Re: Error #1009
                        _Natasha_ Level 4

                        What is the format for myXML?

                        • 9. Re: Error #1009
                          hitesh.rawat Level 1

                          "format for myXML"

                           

                          var myXML:XML ;

                           

                           

                          its XML ..........

                          • 10. Re: Error #1009
                            _Natasha_ Level 4

                            Ok... go another way.

                             

                            try

                            myXML.children()[IndexNumber].attribute("source");

                            • 11. Re: Error #1009
                              hitesh.rawat Level 1

                              it gave .................

                               

                              TypeError: Error #1010: A term is undefined and has no properties.

                              • 12. Re: Error #1009
                                _Natasha_ Level 4

                                post trace(myXML.toXMLString())

                                1 person found this helpful
                                • 13. Re: Error #1009
                                  hitesh.rawat Level 1

                                  yea.....nothing publised................don't know why??

                                  • 14. Re: Error #1009
                                    _Natasha_ Level 4

                                    If it's olso getted from server, it's not ready when you try to use it.

                                    • 15. Re: Error #1009
                                      hitesh.rawat Level 1

                                      well......its in the same folder as the where the .mxml is lying......no server involved.............

                                       

                                       

                                      Following is the AS code........i used the same earlier when i was using SWF loader.....but then i got to know....Loader provides much more functionalities....so i used this loader........and movie clip...............however this function to connect to the XML was working fine...by then.......

                                       

                                       

                                       

                                      <mx:Script>
                                          <![CDATA[
                                             
                                              import flash.display.Loader;
                                              import mx.core.UIComponent;
                                             
                                             
                                               var loader:Loader = new Loader();   
                                               var mc:MovieClip = new MovieClip;
                                              
                                              
                                              public function settingSource(event:Event):void
                                              {
                                              
                                               
                                                      var myXML:XML = new XML(event.target.data);
                                                      var IndexNumber;
                                                      IndexNumber = optionList.selectedIndex;
                                                     
                                                      T.visible = true;
                                                      T.text = myXML.toXMLString();
                                                     
                                                     
                                                      var req:URLRequest = myXML.child(IndexNumber).attribute("source");

                                       


                                                     
                                                      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingCompleted);
                                                           
                                                        loader.load(req);
                                                      loaderPanel.addChild(loader);   
                                           
                                                           
                                           
                                             
                                              }
                                             
                                             
                                               private function loadingCompleted(event:Event):void
                                                  {
                                                      
                                                      if(loader.content == null)
                                                      {
                                                      (event.target.content as MovieClip).play();
                                                       mc = event.target.content ;
                                                      }
                                                      
                                                  }
                                        
                                         
                                          ]]>
                                      </mx:Script>