Skip to main content
January 25, 2012
Question

Can you communicate flash to flash with fscommand?

  • January 25, 2012
  • 1 reply
  • 1101 views

ActionScript 2.0

I have a training lab created from a third party company that my company wants to incorporate into our online training program. The lab uses a fscommand() to send an incorrect message to the software they use to display their flash labs. So the incorrect message ins't displayed in the flash file when they click an incorrect answer, it is displayed in a tiny window at the bottom of the training software they use for all there video and interactive flash file training. So here is my question. We are using (with permission) these flash files in our online training and they are imported through another flash file which we use to allow people to navigate through our training. We would like to be able to display that incorrect message in our flash file. From what I've read you use fscommands to communicate to javascript or C. Can you use it to communicate to another flash file (the flash file that the lab is contained in)? It would make my life a lot easier if I didn't have to change the code for each individual lab file.

Very simple code they use to display the message:

function wrong(){

    fscommand("Incorrect");

}

I don't have access to the software they use to display their flash files. I have no idea how to interpret this command in order to display the incorrect message or if it is even possible. I'm a beginner so sorry if this is confusing. If anyone could help me out a little. I've been searching all over and haven't found anything that has helped.

Thanks!

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
January 25, 2012

here are the various ways to communicate between two swfs:   http://kb2.adobe.com/community/publishing/918/cpsid_91887.html

if one swf is loading another, just skip to that section. 

February 1, 2012

Not sure that is exactly what I need. My problem is I have 200+ labs and counting. They were all created using ActionScript 2.0 and they use the fscommand(). I don't want to go back and add code to each indivdial lab, if possible. I want to be able to use what they already have in place to display an "incorrect" or "correct" answer in my own swf player, which is importing these labs. The swf player I'm using is coded in ActionScript 3.0 btw.

I was curious if there might be a way to use the fscommand() that is already in place to call a javascript function on the page the player is loaded on. Then have the javascript communicate back to my swf player with the results. Not sure if that is possible but maybe someone can help me out with this?

kglad
Community Expert
Community Expert
February 1, 2012

yes, you can but it's not easy.  first, replace xxxx with your main (as3) swf's name and add the following to your html:

<script language="JavaScript">

<!--

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// Handle all the FSCommand messages in a Flash movie.

function xxxx_DoFSCommand(command, args) {

         thisMovie("xxxx").youras3addcallbackfunction(command);  // in your as3 swf you'll need to use the externalinterface addcallback() method.

}

function thisMovie(movieName) {

         if (navigator.appName.indexOf("Microsoft") != -1) {

             return window[movieName];

         } else {

             return document[movieName];

         }

     }

// Hook for Internet Explorer.

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {

    document.write('<script language=\"VBScript\"\>\n');

    document.write('On Error Resume Next\n');

    document.write('Sub text_FSCommand(ByVal command, ByVal args)\n');

    document.write('    Call text_DoFSCommand(command, args)\n');

    document.write('End Sub\n');

    document.write('</script\>\n');

}

//-->

</script>