4 Replies Latest reply on Aug 17, 2010 9:13 AM by dougieweb

    SWFLoader component question

    dougieweb

      Hi,

      Is the SWFLoader compoent a good choice for loading many SWFs in/out of a main application?   In this case, a learner may view five or six during a session (not all at once of course).  These external SWFs are mostly generated by Captivate 4.

       

      Also, how do you unload a SWF that was loaded with the SWFLoader?

       

      Thanks.

      Doug

        • 1. Re: SWFLoader component question
          Flex harUI Adobe Employee

          Set url=null.  The SWF will also get released when a new url is assigned.

          • 2. Re: SWFLoader component question
            dougieweb Level 1

            Hi,

            I was not able to use null in this implementation.  Needed to use the unloadAndStop() function.  I suspect you had something else in mind and since I'm not sure if the way I'm doing it is going to be "best practice,"  I'd certainly welcome the rest of the code that might go with your suggestion.  It it will be too much trouble, I understand.

            Thanks,

            Doug

             

            ?xml version="1.0" encoding="utf-8"?>

            <s:Application

             

             

            xmlns:fx="http://ns.adobe.com/mxml/2009"

            xmlns:s="

            library://ns.adobe.com/flex/spark"

            xmlns:mx="

            library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

             

             

            <s:layout>

             

             

            <s:HorizontalLayout/>

             

             

            </s:layout>

             

             

             

            <fx:Script>

            <![CDATA[

             

             

                 protected function button1_clickHandler(event:MouseEvent):void

                 {

                      loader.load(

            "assets/captivateMovies/cMovie.swf");

                 }

             

             

                 protected function button2_clickHandler(event:MouseEvent):void

                 {

            17.          loader.unloadAndStop();     // could not use loader.unload(null);

                 }

             

            ]]>

             

             

                

             

            </fx:Script>

             

             

             

            <fx:Declarations>

             

             

            <!-- Place non-visual elements (e.g., services, value objects) here -->

             

             

            </fx:Declarations>

             

             

             

            <s:BorderContainer accentColor="0xcccccc" >

             

             

            <mx:SWFLoader id="loader" x="7" y="48" width="922" height="691"/>

             

             

            <s:Button x="10" y="10" label="Start" click="button1_clickHandler(event)"/>

             

             

            <s:Button x="115" y="10" label="Unload" click="button2_clickHandler(event)"/>

             

             

             

            </s:BorderContainer>

            </s:Application>

            • 3. Re: SWFLoader component question
              Flex harUI Adobe Employee

              If the content is "active" you may in fact need to use unloadAndStop.

              1 person found this helpful
              • 4. Re: SWFLoader component question
                dougieweb Level 1

                Yes, the content may or may_not be active.  I'll go with this for now and see how it goes.

                Thanks!

                Doug