10 Replies Latest reply on Dec 3, 2008 2:20 PM by *gsb*

    SfCommand Results: A black Whole?

    Russell.Brown
      I'm writing an app that needs to be wrapped with Swish Studio. I need to interact with the wrapper to do system level operations. How on bloody earth do I get the results from an SfCommand call. I understand that it's not available right away which is why in Flash at a later frame you can use the _root.fscmd_ret variable to get the result....

      So was this just plain left out of Flex? Please Help!
        • 1. Re: SfCommand Results: A black Whole?
          Level 7
          Try ExternalInterface.
          "Russell.Brown" <webforumsuser@macromedia.com> wrote in message
          news:gh4jgu$5jd$1@forums.macromedia.com...
          > I'm writing an app that needs to be wrapped with Swish Studio. I need to
          > interact with the wrapper to do system level operations. How on bloody
          > earth do
          > I get the results from an SfCommand call. I understand that it's not
          > available
          > right away which is why in Flash at a later frame you can use the
          > _root.fscmd_ret variable to get the result....
          >
          > So was this just plain left out of Flex? Please Help!
          >


          • 2. Re: SfCommand Results: A black Whole?
            Russell.Brown Level 1
            Here are my two test lines. The first one works and generates a successful call, the second one does nothing. This a call to an ActiveX wrapper essentialy.

            fscommand("FileAccess", "%Org%\\images");

            ExternalInterface.call("FileAccess", "%Org%\\images");
            • 3. Re: SfCommand Results: A black Whole?
              injpix Level 3
              These quotes are directly from the help docs:

              "Note: For local content running in a browser, calls to the ExternalInterface.call() method are permitted only if the SWF file and the containing web page (if there is one) are in the local-trusted security sandbox. Also, you can prevent a SWF file from using this method by setting the allowNetworking parameter of the object and embed tags in the HTML page that contains the SWF content. For more information, see the following:"

              "Scripting in either direction between local HTML files and local SWF files--for example, using the ExternalInterface class--requires that both the HTML file and SWF file involved be in the local-trusted sandbox. This is because the local security models for browsers differ from the Flash Player local security model."

              So it looks like you need to set 'allowScriptAccess' in your wrapper.

              Take a look here:
              http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Live Docs_Book_Parts&file=passingarguments_086_19.html

              And let us know how it works out.

              • 4. Re: SfCommand Results: A black Whole?
                Russell.Brown Level 1
                The problem is, my "wrapper" is Swish Studio2 not a web page.

                I'm creating a flex screen saver that will be installed on around 1200 corporate computers and pushing AIR to all of these computers is currently not on the table of options. Therefor this seems to be the best way to do this. The interaction with the executable is ActiveX, not JavaScript.

                I have found out that the _root.fscmd_ret variable that sfcommand() sets with a result is the equivalent to Application.application.fscmd_ret. However I can't seem to put a watch on this scope and getting it's value reliably has been difficult. Is there a best practices way via a different method that I can access this?
                • 5. Re: SfCommand Results: A black Whole?
                  injpix Level 3
                  You can still use ExternalInterface for your situation. From the help docs:
                  "Note: If you are publishing for Flash Player 8 or later, the ExternalInterface class provides better functionality for communication between JavaScript and ActionScript (Usage 2) and between ActionScript and VisualBasic, Visual C++, or other programs that can host ActiveX controls (Usage 4). You should continue to use fscommand() for sending messages to Flash Player (Usage 1) and Director (Usage 3)."
                  - http://livedocs.adobe.com/flex/3/langref/flash/system/package.html

                  I found the following thread on forums.swishzone.com:
                  http://forums.swishzone.com/index.php?act=Search&CODE=simpleresults&sid=8b5143bb288ba697e9 df58a53d44a3e2&highlite=ExternalInterface

                  Have you looked at this? sO2 suggests to use an alias reference name. I hope that helps more.
                  • 6. Re: SfCommand Results: A black Whole?
                    *gsb* Level 1
                    In a custom preloader (i.e. Flex frame 1), put a timer loop that tries the fsCommand to set a value to "success" and terminates the preloader when the value is correct.

                    • 7. Re: SfCommand Results: A black Whole?
                      Level 7

                      "Russell.Brown" <webforumsuser@macromedia.com> wrote in message
                      news:gh60vu$suq$1@forums.macromedia.com...
                      > Here are my two test lines. The first one works and generates a successful
                      > call, the second one does nothing. This a call to an ActiveX wrapper
                      > essentialy.
                      >
                      > fscommand("FileAccess", "%Org%\\images");
                      >
                      > ExternalInterface.call("FileAccess", "%Org%\\images");

                      I'm not sure what you're saying here. Are you saying that you're calling to
                      an application other than a web browser that contains the Flash player
                      ActiveX control? I can assure you that ExternalInterface DOES work for
                      this, but you may need to listen on a different event.

                      HTH;

                      Amy


                      • 8. Re: SfCommand Results: A black Whole?
                        Level 7

                        "Russell.Brown" <webforumsuser@macromedia.com> wrote in message
                        news:gh6553$4cf$1@forums.macromedia.com...
                        > The problem is, my "wrapper" is
                        > http://www.swishzone.com/index.php?area=products&product=studio&tab=overview
                        > not a web page.
                        >
                        > I'm creating a flex screen saver that will be installed on around 1200
                        > corporate computers and pushing AIR to all of these computers is currently
                        > not
                        > on the table of options. Therefor this seems to be the best way to do
                        > this. The
                        > interaction with the executable is ActiveX, not JavaScript.
                        >
                        > I have found out that the _root.fscmd_ret variable that sfcommand() sets
                        > with
                        > a result is the equivalent to Application.application.fscmd_ret. However I
                        > can't seem to put a watch on this scope and getting it's value reliably
                        > has
                        > been difficult. Is there a best practices way via a different method that
                        > I can
                        > access this?

                        I have no experience with swish, but you may or may not find this helpful:
                        http://learn.adobe.com/wiki/display/Flex/Moving+to+Flex+from+Authorware
                        Down at the bottom, using Flex files inside Authorware


                        • 9. Re: SfCommand Results: A black Whole?
                          Russell.Brown Level 1
                          I still haven't made and forward movement but I appreciate the help so far. TO clarify some stuff... SWiSH Studio2 has a log that prints out every interaction with it's DLL. As stated above, although not well.... the FsCommand example below connects to the dll and makes it's request. However I still can't seem to find it's result anywhere and anytime. The second example below [external interface call] fires with no errors, but does not actually touch the DLL for reasons unknown to me. Despite all of my reading and the great links provided by Amy, not a single call has resulted in the DLL being reached out to by my Flash app.

                          1) fscommand("FileAccess", "%Org%\\images");
                          2) ExternalInterface.call("FileAccess", "%Org%\\images");

                          I created the following code to try get a value back from fscommand with no success....

                          // -------------------------------------------------------------------------
                          import flash.events.TimerEvent;
                          import flash.external.ExternalInterface;
                          import flash.utils.Timer;

                          import mx.controls.Alert;
                          import mx.core.Application;

                          private var t:Timer;
                          private var tCounter:int=0;

                          private function preLoader():void {
                          trace("pre-init");

                          fscommand("FileAccess", "%Org%");

                          t = new Timer(500, 10);
                          t.addEventListener(TimerEvent.TIMER, preLoader_timer);
                          t.start();
                          }

                          private function preLoader_timer(e:TimerEvent):void {
                          tCounter++;

                          try {
                          Alert.show("this.fscmd_ret: " + this["fscmd_ret"]);
                          } catch (e:Error) {
                          // DO NOTHING
                          }

                          try {
                          Alert.show("Application.application.fscmd_ret: " + Application.application.fscmd_ret);
                          } catch (e:Error) {
                          // DO NOTHING
                          }

                          if (tCounter == t.repeatCount)
                          Alert.show("Done");
                          }
                          // -------------------------------------------------------------------------
                          • 10. Re: SfCommand Results: A black Whole?
                            *gsb* Level 1
                            Hummmm....

                            I have used SWiSHmax extensively but do not have SWiSHstudio.
                            This is a "timing" issue in SWiSHmax (similar to the stage initialization) within an HTML wrapper with JavaScript enabled.

                            I suggest that you make a small browser test example and get it working in your browser. Then try to apply the success to SWiSHstudio.