A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Passing variables to exec function

  1. #1
    Member
    Join Date
    Jul 2003
    Posts
    68

    Passing variables to exec function

    Hello
    I am using fscommand exec function from standalone to open external files on CD. I am also using html text and asfunction. So I have text fieds that have links that call asfunction and fscommand. It sounds complicated but here is the example:

    Code:
    MyTextField.htmlText = "<a href='asfunction:somefunction, openfile.exe'>Click me</a>";
    function somefunction (arg) {
    	fscommand("exec", arg);
    }
    This doesn't work, fscommand will only work if I call it like this

    Code:
    fscommand("exec", "openfile.exe");
    and not if I pass variables to it

    Problem is that I have a lot of links in htmltext and would have to make separate functions for each. Is there a way to lunch exec with variables

    thanks

  2. #2
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,764
    The asfunction method should work fine, just make sure that you don't have extra spaces in arg so that it looks like " openfile.exe", that will cause the exec to fail.

    What exactly are you trying to pass to these external applications? There may a way to run the same file with different arguments as long as the possible range of arguments is fixed. You can create one BAT file for each argument list that can be passed to the EXE file and then just call the BAT file from Flash instead of the EXE. I have some FREE tools that will let you get rid of the ugly DOS box that appears when calling BAT files if you think this might work.

    Unfortunately, without a third party projector tool there's no way to pass a dynamic range of arguments to an EXE file that you launch from Flash. Here's a list of third party tools you might want to have a look at.

    SWF Studio http://www.northcode.com
    Zinc http://www.multidmedia.com
    Jugglor http://www.jugglor.com
    SWFKit http://www.swfkit.com
    mProjector http://www.screentime.com
    SWiSH Studio http://www.swishzone.com
    FlashAnts http://www.flashants.com
    Flash 'N Pack http://www.flashnpack.com

  3. #3
    Member
    Join Date
    Jul 2003
    Posts
    68
    Hello
    thank you for your answer
    the problem is that fscommand exec doesn't work if you use it with expression, exec will not execute:

    MyTextField.htmlText = "<a href='asfunction:somefunction, openfile.exe'>Click me</a>";
    function somefunction (arg) {
    fscommand("exec", arg);
    }

    since I have a large text with a lot of links opening pdf files I have to make a separate fscommand for each. Is there a way to avoid this and why fscommand works only if you use quotes: fscommand("exec", "openfile.exe");?

    I am already using your proxy tool for opening files and it works great. Thanks a lot for this, that is a tool that I was looking for a long time.

  4. #4
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,764
    the problem is that fscommand exec doesn't work if you use it with expression, exec will not execute
    Sure it will, I do it all the time. Are you working in expert mode or normal mode in the ActionScript editor? If you're in normal mode you have to tell it that you want to put an expression in there. The easiest solution is to work in expert mode where you can type whatever you like. If you can't get it working, send me a simple example FLA and I'll fix it up for you. Cheap as free

  5. #5
    Member
    Join Date
    Jul 2003
    Posts
    68
    hello
    sory but I still can't get it to work. It seems that if I send variable with html link and asfunction it doesn't work. I hope that it si some mistake that I made. I used your example for proxy tool and modified it, I am attaching zip file.
    thanks
    Attached Files Attached Files

  6. #6
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,764
    This code works.

    Code:
    myTextField.htmlText = "<a href='asfunction:open_file,proxy.exe'>open file</a>";
    
    function open_file(arg) 
    {
       fscommand("exec", arg);
    }
    The only problem with your function was the space after the comma. Instead of "open_file, proxy.exe" it should have been "open_file,proxy.exe". You were trying to launch an EXE called " proxy.exe" which didn't exist.

  7. #7
    Member
    Join Date
    Jul 2003
    Posts
    68
    thanks thanks thanks
    very stupid mistake
    thanks again for all your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center