5 Replies Latest reply on Oct 8, 2007 10:22 AM by tvtony100

    Loading Flash SWF into Flex.

    vinothPrakasam
      Hi all,

      I have loaded a swf file into my flex application using SWFLoader as below

      <mx:SWFLoader id="s1" source="map.swf" />

      My problem is , how to pass values or call some methods in map.swf from my application.

      if i click any button inside map.swf, how to get values from that swf to my main application.

      anyone please tell me how to do this.

      Thanks in advance

      Regards
      Vinoth.
        • 1. Re: Loading Flash SWF into Flex.
          slaingod Level 1
          There are some examples out there like:
          http://renaun.com/blog/2005/08/30/4/

          However, I'm not sure if that works when the other SWF is another Flex app. I tried it but was never able to get it to work in that case.

          I have a related issue with LocalConnection between 2 Flex apps, one SWFLoader'd by the other. The problem is I need to set up a unique LC channel between the two apps, but I also have multiple instances of the child app ( a movie player). Even if my app only has one player, if the app is loaded on 2 different tabs, the LocalConnection still only talks to the one. It seems this would always be the case, but that somehow this is never discussed in any of the examples.
          • 2. Re: Loading Flash SWF into Flex.
            ntsiii Level 3
            You can access public members of the loaded swf using s1.content.myPublicMember.

            You can access members in the parent app using parentApplication.

            Be careful of timing issues.

            I have a full example on cflex.net, search for swfloader

            Tracy
            • 3. Re: Loading Flash SWF into Flex.
              slaingod Level 1
              Yes I found:
              http://www.cflex.net/showFileDetails.cfm?ObjectID=690
              last night, and that worked for me on a Flex app. The only change I had to make was to turn strict type checking off in the compiler options and get rid of the SWFLoaded() cast. Wasn't enough of a guru to figure out how to get the type info from the other app into parent.
              • 4. Loading Flash SWF into Flex.
                slaingod Level 1
                So that does bring up the question, if you wanted to leave strict typing on, how would you include the other apps mxml 'header' definition? So that SWFLoaded(_appLoaded).some_method(); would work? Just not familiar enough with actionscript to answer that one.

                Edit: So not necessarily the answer to my question, but you can use

                var _appLoaded:*;

                to disable strict type checking for a single variable, while leaving it ennabled elsewhere.
                • 5. Re: Loading Flash SWF into Flex.
                  tvtony100 Level 1
                  Yes, I have it kind of working but am experiencing the same problem with the cast as well and even if I disable the strict compiler option I get runtime errors.
                  Has anyone figured out how the correct way to call the inner function from the outer?

                  Thank's.