9 Replies Latest reply on Nov 27, 2007 1:16 AM by callie16

    Embedding swf

      hello again...

      i seem to be having a problem embedding an external swf file to my flex app. i place a SWFLoader inside a VBox and the SWF being embedded is called from a cgi. However, once it loads, the whole page freezes yet, when I embed a simple swf "image", nothing freezes... Any help would be appreciated! =)
        • 1. Re: Embedding swf
          ntsiii Level 3
          Are you using the word "embed" in its technical Actionscript sense?

          Exactly what do you mean by "called from a cgi"

          Post some code.

          • 2. Re: Embedding swf
            callie16 Level 1
            i hope i am (newbie)... anyway, i'll try to explain coz i'm not sure if i'm implementing it right :)

            in our app, we cannot use flex charting (due to costs) so we are using some other opensource graphing api. but, before we can load the actual graph, we generate the data in the backend using a perl script... hence, a cgi is used. so, using httpservice, i call the cgi... then, after the httpservice ends, a function is called and it loads the swf file (the graph).

            so... it goes roughly something like this:

            <mx:VBox preinitialize="initApp()">
            <mx:HTTPService id="httpId" url="urlof.cgi" result="generateGraph()" method="POST" />
            private function initApp():void {
            // statements pertaining to crossdomain ...

            private function generateGraph():void {
            // some other statements
            loaderId.load(" [url of the swf file] ");

            <mx:SWFLoader id="loaderId" />

            please also note... the reason why i can't use other implementations that i've found so far is that the url of the swf file requires that the file containing the values be passed as a parameter (e.g. flash.swf?data.txt)

            the problem is, on first load it works... on succeeding loads, it makes the whole application hang (even if other screens are loaded). is there a better way of implementing this?

            thanks! :)
            • 3. Re: Embedding swf
              ntsiii Level 3
              Ok. You are not embedding the swf, but rather loading it at run time. "Embed" has a very specific meaning in Flex.

              There is no reaso why this will not work. I swap swfs in and out of SWFLoader constantly. It is the primary architecture of one of my main apps.

              Try this. Instead of loaderId.load(" [url of the swf file] ");
              loaderid.source = sUrlofSWFFile; //set the source property instead of using load

              For display only, it shouldn't matter, but are the generated graph swfs FP9/AS3 swfs? FP8/AS2 swfs should load fine, but are difficult to "control"

              • 4. Re: Embedding swf
                callie16 Level 1
                hi tracy

                i tried setting the source property but the effect's the same :( then, we checked the implementation of the graph tool, it was made using FP8/AS2. we don't necessarily need to control the swf file; we just load it and leave it to its own devices, so to speak... we just don't understand why it halts everything :(

                thanks so far for the help :)
                • 5. Re: Embedding swf
                  callie16 Level 1
                  btw, we used Open Flash Chart -> http://teethgrinder.co.uk/open-flash-chart/

                  thanks :)
                  • 6. Re: Embedding swf
                    ntsiii Level 3
                    Ok, make a couple simple SWFs in Flex, and try to load them. See if the issue is with the generated swfs.
                    • 7. Re: Embedding swf
                      ntsiii Level 3
                      Oh, i see you did that first, hmm.
                      • 8. Re: Embedding swf
                        callie16 Level 1
                        hmm... that's what we tried the first time... so we knew it wasn't that particular case... then, we tried loading very simple external swfs (a simple animation) and it had no problems... hmm...
                        • 9. Re: Embedding swf
                          callie16 Level 1

                          i seem to be getting the Error #1056... the source of the swf is an external xml file, as i've mentioned earlier... does this make a difference?