5 Replies Latest reply on Sep 17, 2009 9:32 AM by Flex harUI

    Unload()

    hitesh.rawat Level 1

      Hi,

       

      I made this application to play swf files...........using loader.

      So, i'm able to play the file.....however while stopping.....i'm using unload() method.

      It Unloads the video......however i can still hear the sound...........how to stop that.....????????????

       

       

      private function loadingCompleted(event:Event):void
                  {
                      
                      if(loader.content == null)
                      {
                         
                      (event.target.content as MovieClip).play();
                      
                       mc = event.target.content ;
                      
                      }
                      
                  }
                
                  private function onStop(event:Event):void
                  {
                 
                  if(loader.content !== null)
                  {
                  loader.unload();
                  }

        • 1. Re: Unload()
          _Natasha_ Level 4

          Hi,

          the first one.

          What for this structure?

          private function onStop(event:Event):void
          {
                     
                      if(loader.content !== null)
                      {
                      loader.unload();
                      }

          }

           

          You can use at a simple way:

          private function onStop(event:Event):void
          {
                     
                      if(loader.content)
                      {
                      loader.unload();
                      }

          }

           

          The second.

           

          Why do you thibk that unload() will destroy your content? It's written in docs, that this method only remove links from Loader object and nothing more.

          "Removes a child of this Loader object that was loaded by using the load() method. The property of the associated LoaderInfo object is reset to null. The child is not necessarily destroyed because other objects might have references to it; however, it is no longer a child of the Loader object."

          1 person found this helpful
          • 2. Re: Unload()
            hitesh.rawat Level 1

            well i'm new to Flex and action script.......

             

            I thought Unloading the content would unload the file. I read the docs.....thought it would unload.....the object. It's bit confusing that......after the URL to the loader and loaded content is set to null..... it still plays the sound ??

            • 3. Re: Unload()
              _Natasha_ Level 4

              Content will not be destroyed while there ia an active links to it.

              So you should stop playing, call unload() and set to null all other link to your content. After that content will be free.

              1 person found this helpful
              • 4. Re: Unload()
                hitesh.rawat Level 1

                Well i started with stopping the file however that didn't work.....so i tried with unload().

                • 5. Re: Unload()
                  Flex harUI Adobe Employee

                  You can use unloadAndStop to stop audio, but you'll still need to undo all other links to get the file to actually unload.

                   

                  Alex Harui

                  Flex SDK Developer

                  Adobe Systems Inc.

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