View comments | RSS feed

fscommand()

Availability

Flash Player 3.

Usage

fscommand("command", "parameters")

Parameters

command A string passed to the host application for any use, or a command passed to Flash Player.

parameters A string passed to the host application for any use, or a value passed to Flash Player.

Returns

Nothing.

Description

Function; lets the SWF file communicate with either Flash Player or the program hosting Flash Player, such as a web browser. You can also use the fscommand() function to pass messages to Macromedia Director, or to Visual Basic, Visual C++, and other programs that can host ActiveX controls.

Usage 1: To send a message to Flash Player, you must use predefined commands and parameters. The following table shows the values you can specify for the command and parameters parameters of the fscommand() function to control a SWF file playing in Flash Player, including projectors.

Command Parameters Purpose
quit
None

Closes the projector.

fullscreen

true or false

Specifying true sets Flash Player to full-screen mode. Specifying false returns the player to normal menu view.

allowscale

true or false

Specifying false sets the player so that the SWF file is always drawn at its original size and never scaled. Specifying true forces the SWF file to scale to 100% of the player.

showmenu

true or false

Specifying true enables the full set of context menu items. Specifying false dims all the context menu items except About Flash Player.

exec

Path to application

Executes an application from within the projector.

trapallkeys

true or false

Specifying true sends all key events, including accelerator keys, to the onClipEvent(keyDown/keyUp) handler in Flash Player.

The exec command can contain only the characters A-Z, a-z, 0-9, period (.), and underscore (_). The exec command runs in the subdirectory fscommand only. In other words, if you use the fscommand exec command to call an application, the application must reside in a subdirectory named fscommand.

Usage 2: To use the fscommand() function to send a message to a scripting language such as JavaScript in a web browser, you can pass any two parameters in the command and parameters parameters. These parameters can be strings or expressions and are used in a JavaScript function that handles, or catches, the fscommand() function.

In a web browser, the fscommand() function calls the JavaScript function moviename_DoFScommand in the HTML page containing the SWF file. The moviename is the name of the Flash Player as assigned by the NAME attribute of the EMBED tag or the ID property of the OBJECT tag. If you assign the Flash Player the name myDocument, the JavaScript function called is myDocument_DoFScommand.

Usage 3: The fscommand() function can send messages to Macromedia Director that are interpreted by Lingo (Director's scripting language) as strings, events, or executable Lingo code. If the message is a string or an event, you must write the Lingo code to receive the message from the fscommand() function and carry out an action in Director. For more information, see the Director Support Center at www.macromedia.com/support/director.

Usage 4: In Visual Basic, Visual C++, and other programs that can host ActiveX controls, the fscommand() function sends a VB event with two strings that can be handled in the environment's programming language. For more information, use the keywords Flash method to search the Flash Support Center at www.macromedia.com/support/flash.

Example

In the following example, the fscommand() function sets Flash Player to scale the SWF file to the full monitor screen size when the fullscreen_btn button or unfullscreen_btn is released:

this.fullscreen_btn.onRelease = function() {
   fscommand("fullscreen", true);
};
this.unfullscreen_btn.onRelease = function() {
   fscommand("fullscreen", false);
};

The following example uses the fscommand() function applied to a button in Flash to open a JavaScript message box in an HTML page. The message itself is sent to JavaScript as the fscommand parameter.

You must add a function to the HTML page that contains the SWF file. This function, myDocument_DoFSCommand, sits in the HTML page and waits for an fscommand() function in Flash. When an fscommand is triggered in Flash (for example, when a user presses the button), the command and parameter strings are passed to the myDocument_DoFSCommand function. You can use the passed strings in your JavaScript or VBScript code in any way you like. In this example, the function contains a conditional if statement that checks to see if the command string is "messagebox". If it is, a JavaScript alert box (or "message box") opens and displays the contents of the parameters string.

function myDocument_DoFSCommand(command, args) {
   if (command == "messagebox") {
      alert(args);
   }
}

In the Flash document, add the fscommand() function to a button:

fscommand("messagebox", "This is a message box called from within Flash.")

You can also use expressions for the fscommand() function and parameters, as in the following example:

fscommand("messagebox", "Hello, " + name + ", welcome to our website!")

To test the SWF file, select File > Publish Preview > HTML.

Note: If you publish your SWF file using the Flash with FSCommand template in the HTML tab of the Publish Settings dialog box, the myDocument_DoFSCommand function is inserted automatically. The SWF file's NAME and ID attributes will be the filename. For example, for the file myDocument.fla, the attributes would be set to myDocument.


Comments


recoveredfromflashMX2004 said on Aug 4, 2004 at 2:40 PM :
No screen name said on May 14, 2004 at 10:07 AM :

If you're launching an executable from a CD, the executable must be located in a folder called fscommand in the root of the CD. You launch the file by using:

fscommand("exec", "filename.exe");

Note you don't have to include the fscommand folder in the path.
sandhanagopal said on Aug 25, 2004 at 4:20 AM :
Hi,
I am using fscommand for a button to open a executable file which is in the same location.

i am using Flash MX 2004 Professional Version 7.2.
on release of a button i m opening a executable file code is below.


on(release) {
fscommand ("exec", "bro1.exe");
}

the same code is working fine in flash 5. is anyother settings i have to follow.

waiting for your reply.
Francis Cheng said on Aug 25, 2004 at 12:25 PM :
We tightened our security model with Flash Player 6, so for Flash Player 6 and later you need to place your executable ("bro1.exe" in your example) in a subfolder called "fscommand". The fscommand folder must be a "sibling" to your flash projector movie.
No screen name said on Aug 30, 2004 at 3:04 PM :
So, would this be correct then:

on(release) {
fscommand ("exec", "fscommand.bro1.exe");
}

or this:

on(release) {
fscommand ("exec", "fscommand/bro1.exe");
}
Francis Cheng said on Aug 30, 2004 at 3:37 PM :
Thanks for your question. The code can stay the same as it was for Flash 5:

on(release) {
fscommand ("exec", "bro1.exe");
}

Only the location of the file "bro1.exe" must be changed such that it lives in a subfolder named "fscommand". See the following technote for detailed information about using fscommand with projector files:
http://www.macromedia.com/support/flash/ts/documents/fscommand_projectors.htm
asus said on Aug 31, 2004 at 11:25 AM :
when will there be support for macintosh fscommands.
I am having a hard time with the EXEC, trying to run applescripts.

// pim@emakina.com
No screen name said on Sep 1, 2004 at 10:39 AM :
I would like to set the size of a movie within a movie. Usually, one wouldn't have to worry about this, except I want the first movie to simply "house" the second movie.

The first movie is set to full screen with fscommand, while the second movie needs to remain 400w x 200h.

The trick is that I can't use HTML or JavaScript, because it's for a CDROM and has to be published as an .exe.

Thank you,

Ken
Ahmed Sabry said on Sep 13, 2004 at 4:52 AM :
it's so easyto take a step into th "fscommand" folder,but it also needs to be done in the opposite direction.
it shouldn't be a one way term
No screen name said on Oct 12, 2004 at 4:32 AM :
Regarding fscommand, I have put "Autumn.exe" in a folder called 'fscommand'. This folder sits right next to 'intro.swf'. In 'intro.swf' I have a movieclip (Instance name 'newPuzzle1'), and frame 1 of intro.fla has this code:
newPuzzle1.onPress = function() {
fscommand("exec", "Autumn.exe");
}
Why won't 'Autumn.exe' run?
Francis Cheng said on Oct 12, 2004 at 8:49 AM :
For security reasons, you can only use "exec" with standalone projector files. From your description it sounds like you are attempting to use "exec" within a .SWF file instead of within a .EXE projector file. In other words, you have to save your "intro.swf" file as a projector file ("intro.exe").
No screen name said on Oct 12, 2004 at 3:30 PM :
Thanks! I had just worked that out and was coming to tell you! It's only a small point, that 'exec' commands will only run from a projector, but it isn't mentioned in any of the help I've seen both here and in other forums. Now I can get back to the fun stuff...
Babroo said on Oct 13, 2004 at 1:17 PM :
After including some text, turn it into a Symbol, mainly a button(Symbol 1) I include this action:

on (release) {
fscommand("exec", "firefox-1.0PR.es-AR.win32.installer.exe");
}

The file in question is located in the FSCOMMAND subfolder.

I publish it as a projector file (.EXE file) but when I execute it, it doesn't run the file. What am I doing wrong?
Babroo said on Oct 15, 2004 at 8:51 AM :
After waiting and waiting for someone to reply, I discover the solution.

I rename the file to firefox_installer.exe

Apparently to much dots confuse the program :S

Thanks?
No screen name said on Dec 2, 2004 at 2:55 PM :
Usage 3 must be obsolete in Macromedia Director MX 2004. For the life of me I can't get fscommand() to communicate back to the Director host.
wttewaall said on Dec 19, 2004 at 6:18 AM :
It's not limited to just exe-files, I just figured out that it's possible to open a .bat file. That way the posibilities are endless, since you can write a batchfile to execute all sorts of things.
No screen name said on Dec 28, 2004 at 10:34 PM :
Hi every body. I created my fscommand folder and included all my .exe files and run pretty good the problem starts when I copy a subfolder (include cab files) to the fscommand folder, it doesn't work. I tried with different variations //fscommand("exec", "somefolder/somefile.exe"), "./somefolder/somefile.exe", "../somefolder/somefile.exe", etc

What am I doing wrong?... Please help... Thanks JPM
madjiinx said on Jan 13, 2005 at 11:48 AM :
Blah - Is there some restriction against using the exec command to open up other projectors?

I tried to do this:

on (release) {
fscommand("exec","RCDemoCD.exe");
}

In Flash 7 AS2 and Flash 6 AS2 and no dice -

I am using the projector when clicking and the file RCDemoCD.exe is sitting right there next to my host projector.

What is the problem?
Francis Cheng said on Jan 16, 2005 at 9:53 PM :
Hi JPM,

Sorry, but I don't think that what you are trying to do is possible directly. One way to work around it is to "daisychain" your fscommands. Your first projector can execute a second projector in your fscommand folder, and the second projector can execute a third projector that lives in a subfolder of the fscommand folder. The caveat is that the subfolder must also be named "fscommand" in order for this to work.
Francis Cheng said on Jan 16, 2005 at 9:55 PM :
Hi madjiinx,

There is no restriction against using the exec command to execute other projectors. It sounds like you placed your second projector in the same directory as your first projector. The second projector, "RCDemoCD.exe", must be placed in a subfolder called "fscommand".
Sankey said on Jan 21, 2005 at 12:18 PM :
For trapallkeys, does this only work in the projector version? We're doign a simulation of another product and need to be able to access the function keys for specific features, and it doesn't appear as though using trapallkeys traps these keys. Any ideas on how to trap the function keys?
Francis Cheng said on Jan 24, 2005 at 12:24 PM :
Hi Sankey,
trapallkeys works in the other players as well, but its behavior varies depending on the host environment. In my testing, I was able to trap the function keys in both test movie mode (make sure Control > Disable Keyboard Shortcuts is checked) and the standalone player, but the browser seems to intercept and/or interpret some of the function key presses before the player gets them.

I have a textfield named “keycodepressed” on my stage with the following code:
var trapKey = new Object();
trapKey.onKeyDown = function(){
keycodepressed.text = Key.getCode();
};
Key.addListener(trapKey);
fscommand("trapallkeys", "true");
No screen name said on Jan 27, 2005 at 2:48 AM :
hi,
i was trying to disable the esc key in my app.exe to avoid fullscreen toggling. i used "trapallkeys" function and it is working...
But if i use trapallkeys function, all the text fields that i am using throughout my application... in which the control C or control V is not at all working.. It shows me a small box inside the textfield...
If i remove the trapallkeys function everything is normal...
But i need to avoid fullscreen toggling.. and also it should not affect any textfields to copy or paste texts... Please help me.... its very urgent..
No screen name said on Feb 1, 2005 at 8:00 PM :
hi.
I am using FSCommand to communciate From Flash to browser.
my env:Flash mx 2004 Pro 7.2
platForm :Linux,
browser: Netscape 7.1(above)

my test codes r as follows: for example.
onRelease(){
fscommand("setStatus", "you r login");
}
In Windows 2k platform ,
published with FSCommand template in publish setting,
and added codes in
function myDoc_DoFSCommand(command, args) {
var myDocObj = isInternetExplorer ? document.all.myDoc : document.myDoc;
if (command == "setStatus"){
window.status = args;
}
}
everything seems ok, and works fun.

In netscape on Linux 9.0,does it okay?
Linux9.0 support FSCommand official?
in <a href ="http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_14159"> A comprehensive list of supported Macromedia Flash features, specific to each browser </a>
it didn't declare that it support FSCommand, but it does work well.
anyone advice!
#MyBoss wanna me got a clear answer, but how can I!
thanx!
OTGI said on Feb 2, 2005 at 12:17 PM :
I would like to trap function keys in flash while viewing them in Internet Explorer 6.X. I am unable to trap F5. If the web page the user is on has focus I can trap it. However, if the flash file has focus I can not. I know it works in a projector file but I want it to work with a swf. How can I accomplish this?
Francis Cheng said on Feb 3, 2005 at 10:46 AM :
fscommand() should work on Linux 9 with Netscape 7.1.
No screen name said on Feb 6, 2005 at 2:48 PM :
I am creating a cd-rom application. I am setting both allowscale and showmenu to false. This causes an empty border to appear at the top and bottom of my projector.

Is there any way around this? I would like to hide the menu but also disable scaling because the content is mainly video-based.

I have been told that third party applications can correct this problem. I do not want to go this route. I have also read that you can "hack" the version of the flash player in the projector to remove the menu and avoid the border problem. Are there any more simple solutions?
No screen name said on Feb 21, 2005 at 1:41 AM :
Dear Flash developers...

I have a big problem with the fscommand() function. The fscommand() function actually performs a HTTP Request to the browser. Is there a way to avoid this?
I need to trigger a JavaScript function in my HTML document from within my Flash Movie WITHOUT initiating a HTTP Request. Is this posible? Does the FSCommand trasparently uses the getURL function?

Thanking you in advance.

Jason
No screen name said on Feb 21, 2005 at 1:47 AM :
I am trying to use the fscommand function to communicate on a vb.net web form . Could someone please tell me what references etc to use on the VB.net end. I've added the flash.ocx component but vb.net still cannot see the fscommand. Any help would be greatly appreciated. Cheers Rob
aponex said on Feb 25, 2005 at 1:35 PM :
Hi
I’m having trouble with the FSCommand. This is my ActionScript:

on(release){
fscommand("upvolume","1000");
}

The ID of my swf is "volume" and this is in my HTML document:

function volume_DoFSCommand(command, args) {
var sound=-1000
var volumeObj = isInternetExplorer ? document.all.volume : document.volume;
if (command == "upvolume") {
document.Player.Volume=(sound+args);
}
}

I can’t see what I’m doing wrong. Any help would be appreciated. Thanks in advance

-Apone-
No screen name said on Apr 19, 2005 at 9:03 AM :
Hi flash developers,
I have a problem while executing programs with arguments using fscommand

Lets say I do like this:
fscommand("exec","app.exe")

----> It works fine, no problem :)

But if I do like this:
fscommand("exec","app.exe some_parameter")

-----> It just won't work :(

Does Flash support executing programs with arguments (parameters) or not, and if yes is there a special syntax I have to you use to pass the parameters to the executable?

Thanks,
Mihnea
JakeFreeberg said on Apr 20, 2005 at 1:36 PM :
I didn't see this comment, so hopefully people can find this and not have the headache I did...

fscommand("exec"
is very sensitive about file names,
I don't know if its has anything to do with adding parameters to executions, but it wouldn't run my exe when it had a dash "-" and a underscore "_"in the filename.

watchout for that.
derek233 said on May 18, 2005 at 3:57 PM :
Well, i am using MX 2004 and creating a Flash Projector in AS2 and player 7. i am trying to launch another flash project using

fscommand("exec", "fscommand/test.bat");

And i am getting NOTHING to work. I tried it without the bat file too. all the suggestions on this page failed. Anyone got any advice?
No screen name said on Jun 2, 2005 at 6:43 AM :
Using fscommand("exec", ...) in published swf files:
Is it possible? For applications run on Unix, flash projectors will not work (.exe's). I have to be able to run either a script or program from Flash that will run from a swf Flash clip embedded in an HTML browser. Is this possible with fscommand and if not, does anyone know of any alternatives?
No screen name said on Jun 2, 2005 at 12:54 PM :
As a follow-up to my previous message, I have now evaluated getURL, MMExecute, and JASPI. My problem again is running a script or program in either the Flash, JavaScript, or HTML code that makes up my Flash application that is embedded in a Mozilla browser on a Unix platform.

I have found that getURL will succeed in loading programs and scripts but only from the Internet Explorer browser, and after toggling with settings all day, I am convinced the Mozilla browser code would have to be modified in order to load programs and scripts in the same fashion as I-Explorer does.

As for MMExecute, it will only execute JavaScript strings, and I am having just as much trouble executing programs/scripts from JavaScript as I am from Flash. Finally, I looked into Flash JASPI and its C-level extensibility mechanism that allows you to define functions using C, bundle them in a DLL (Windows) or a shared library (Mac), save the library, and then call the functions from JavaScript using the Flash JASPI. However, there is no mention of support for Unix. If Unix was supported then I guess the shared library containing the C functions would have to be something like "so".

Anyway, I am stumped trying to execute scripts from browsers. With all the security issues involving the execution of scripts by hackers from browsers, I am not surprised. However if there anyone has any ideas that might help, I would greatly appreciate them.

Thanks in advance,
Rob
No screen name said on Jun 2, 2005 at 6:37 PM :
Hi pleas I need this information be4 tuseday am tring to open an microsoft access file in flash whith fscommand ("exec"."accessfilename.mbd")
but i've got nothing
plz help me wuhat can i do?
plz respond me to my e-mail: japo13@lycos.es
No screen name said on Jun 3, 2005 at 6:28 AM :
Even if you put the file in the fscommand folder and fix your spelling (comma instead of period; .mdb instead of .mbd), you probably still won't be able to open Access with fscommand. I've only been able to open self executing files (scripts and executables) with fscommand.

However, being the nice guy I am, I tried getURL and I got it to work. I tested the code and it works for both Internet Explorer and Mozilla browsers (If you want it to open automatically without the notification popup you will have to customize your settings for handling mdb files). Also, it works for both projections (.exe flash programs) and published HTML Flash (swf embedded in HTML). But anyway here's the code I got to work:

getURL("fscommand/db1.mdb", "_blank");

Pretty simple!
Now if the developers could get getURL to execute scripts and executables in mozilla browsers (works for IE), then I'll be in business.

-Rob
No screen name said on Jul 14, 2005 at 12:53 PM :
I am using the fscommand to run the executable mplayer.exe with an argument to it. When I just use mplayer.exe without the argument Bewafaa.wmv, it works fine. But when I try to use an argument for the mplayer.exe, it does not work using the projector file.

on (release) {
fscommand("exec","mplayer.exe Bewafaa.wmv");
}

Can someone please help me in this regard? does fscommand support passing arguments to the executable file. mplayer.exe and Bewafaa.wmv both are sitting in the ./fscommand directory. Please help me out.
No screen name said on Jul 17, 2005 at 12:37 PM :
I have the same need as mentionned below:
I want to send some parameters to an exe.
I tried those syntax but every time, but just the .exe, it won't open the file.
fscommand("exec","dirFile.exe c:\\");
fscommand("exec","\"dirFile.exe c:\\\"");
fscommand("exec","dirFile.exe \"c:\\\"");
I even tried just a string like that:
fscommand("exec","dirFile.exe c");

If there's any way to send parameter, please, help me or tell me if not, I'll stop wasting time about that.
blackMil said on Jul 25, 2005 at 1:33 AM :
I am trying to use the fscommand to close the window but I can not do so the code is:
this.back_btn.onPress = function(){
//trace("close");
_abc.fscommand("quit");
}
wyrmhaven said on Jul 27, 2005 at 5:37 AM :
Hello all. I am trying to get a simple(or at least i thought it would be...) movie clip to accept information into it from either the browser or a remote server. Now I can use PHPObject and all that fun stuff on a LAMP server. But i cannot pass variables into the movie file from the browser at all. Is there ANY way for me to information into the flash player? At the very least is there some way of making the flash player "aware" of session variables? Something??
No screen name said on Jul 27, 2005 at 2:01 PM :
I'm not sure if I understand your problem exactly, but I've there to be several ways to go about communicating from html/javascript back to flash if that is what you're asking. I suggest you check out set and getVariable and the other Flash Javascript methods that are out there. As its set up, you can only change set variables of an embedded flash clip from javascript. However, if you wish to trigger an actual Flash function from javascript, then you will need to use Flash's built in Watch function for the setVariable that you change. Some helpful urls include:

http://www.helpqlodhelp.com/blog/archives/000059.html
http://osflash.org/doku.php?id=flashjs

Hope this helps.
-Rob
cpoelker said on Aug 9, 2005 at 12:32 PM :
Can you have subfolders in the fscommand directory? I would like to access different projects existing as separate executables without renaming core components for each project.
sreema said on Aug 11, 2005 at 9:37 PM :
can any body helpme out to make a minimize and maximize window button...
No screen name said on Aug 15, 2005 at 12:44 PM :
I need to pass a parameter to a BAT file using the fscommand exec, but the parameter is separate by a tab or space form the bat filename.

This article [1] suggets that is not possible to pass a parameter to a batch file using Macromedia Flash MX, only using Flash 5.

Please help me!

[1] http://www.beyondflash.com/content/ch05.htm
No screen name said on Aug 18, 2005 at 6:38 AM :
am i missing something?

im trying to get a flash player (swf) to change the properties of a div tag in the html page its embedded on.

simply:

<script LANGUAGE="JavaScript">
<!-- Hide JavaScript from old browsers
function banner_DoFSCommand(command, args)
{
if ( command == "popup" )
{
if(args == "1"){
document.getElementById("popupwindow1").style.display="block";
document.getElementById("popupwindow2").style.display="none";
document.getElementById("popupwindow3").style.display="none";
}
if(args == "2"){
document.getElementById("popupwindow1").style.display="none";
document.getElementById("popupwindow2").style.display="block";
document.getElementById("popupwindow3").style.display="none";
}
if(args == "3"){
document.getElementById("popupwindow1").style.display="none";
document.getElementById("popupwindow2").style.display="none";
document.getElementById("popupwindow3").style.display="block";
}
if(args == "0"){
document.getElementById("popupwindow1").style.display="none";
document.getElementById("popupwindow2").style.display="none";
document.getElementById("popupwindow3").style.display="none";
}
}
}

// done hiding -->
</script>
<script LANGUAGE="VBScript">
<!--
Sub banner_FSCommand(ByVal command, ByVal args)
call banner_DoFSCommand(command, args)
end sub
// done hiding -->
</script>

my code doesn't work anywhere without the bottom bit i.e... sub and call functions, but it doesn't work in firefox or netscape regardless! i.e is perfect - as usual ;)

any help?
r_sdesign said on Sep 22, 2005 at 5:48 AM :
hi,
in my computer the action

on(release) {
fscommand ("exec", "ferramenta.exe");
}
works just fine, but if i try to play my exe file in another computer , the "ferramenta.exe" wont open
could you give a hand???
Rui S
GI2000 said on Sep 24, 2005 at 3:09 PM :
My first time with fscommand...I'm using Flash MX2004, version 7.2.

I have a Flash .exe in a folder. It contains a subfolder called 'fscommand'. In the folder 'fscommand' is an executable file 'zflicks.exe' that I want to run.

In my Flash file, I have a button with this script:
on (release) {
fscommand("exec","fscommand/zflicks.exe");
}

I've also tried this:
on (release) {
fscommand("exec","fscommand.zlicks.exe");
}

When I create the project file, the button doesn't call up the executable. Can anayone tell me what I am doing wrong?
kev - signals.co.uk said on Apr 7, 2006 at 2:14 AM :
"I am setting both allowscale and showmenu to false. This causes an empty border to appear at the top and bottom of my projector."

it seems the quick work around is setting the publish height a minus 19px (the height of the menu).

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001352.html