dcsimg
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 21

Thread: Hook a button up to open a word document?

  1. #1
    Member
    Join Date
    May 2006
    Location
    UK
    Posts
    92

    Hook a button up to open a word document?

    Hey guys, I need to hook a button up to open a word document, could someone please tell me the code to use?

    thanks a lot for any help you can provide.peace.

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Doesn't getURL() serve your purpose?
    code:

    getURL("mydocument.doc", "_blank");


  3. #3
    Member
    Join Date
    May 2006
    Location
    UK
    Posts
    92
    No it doesnt mate, I did try that but it just opens a blank browser window. I thought it would work as it usually works for more than just open URL's. Any more ideas?

    thanks, Nick

  4. #4
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    You could zip it and use getURL().

    Another way, if your server supports php, is using a script to force download:
    PHP Code:
    <?php 
    // download.php 
    // retrieve the filename to download from the query string of the page 
    $file $_GET['filename']; 

    // send the headers 
    header("Content-type: application/octet-stream"); 
    header("Content-disposition: attachment; filename=$file"); 
    // and output the contents of the file 
    readfile($file); 
    ?>
    // call it from Flash:
    code:

    getURL("download.php?filename=documentfilename.doc ");


  5. #5
    Member
    Join Date
    May 2006
    Location
    UK
    Posts
    92
    ah thanks for your help but im not actually hosting the flash file online, I am converting to a .EXE so that I can burn it to disc and the flash will be like a menu to open up word documents and videos. So any ideas on how I can hook it up like that? thanks for taking the time to type out that actionscript though

    peace.

  6. #6
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    im not actually hosting the flash file online, I am converting to a .EXE
    That's the first thing you should have mentioned.
    Also, you're posting in the wrong forum.

    Use Northcode's proxy which appears in this post. There it's used to open a .pdf, but opening a .doc should be the same.

  7. #7
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    Moved from the Scripting & Backend to the Standalone & Applications forum.

  8. #8
    Member
    Join Date
    May 2006
    Location
    UK
    Posts
    92
    I dont mean to be a dick, but you just presumed that I was going to be hosting the file online, thanks for the help.

  9. #9
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    No problem.

    Sure I did!


    Because if it weren't to be online - which is the most common practice - I'd expect you to mention it.

    As you posted in the Scripting & Backend forum, I didn't have a second though about it. It was obvious it would be online.
    If you had posted it here, in the Standalone & Applications forum, It was obvious it wasn't meant to be online.

    Did you also notice my first and cautious approach?
    Doesn't getURL() serve your purpose?
    I'd also expect people to say something like: "I tried this and that, and it didn't work."
    But that's all explained in the AS Forum Guidelines.

    The better the questions, the better the answers!

  10. #10
    Member
    Join Date
    May 2006
    Location
    UK
    Posts
    92
    I notice people arnt very polite as a whole on this forum, why would I say "I tried this and that, and it didn't work." when I can put it a but more polite, anyway theres no point in arguing or anything, il just use different forums in future.peace.

  11. #11
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    I notice people arnt very polite as a whole on this forum
    Don't give up on us too quickly, there are a lot of good people here. What you think is someone being impolite may be a language issue or just a function of how swamped they are on any given day.

    You chose to post in Scripting and Backend and not Flash General because you thought is was more appropriate. nunomira just pointed out that there was an even better place for you to get help.

    Pointing out that you're posting your question in the wrong forum wasn't rude and you got a link to the answer you needed as well (or a pointer in the right direction).

    but you just presumed that I was going to be hosting the file online, thanks for the help
    If you posted your question here then I would have assumed that you were trying to open a file on disk. Context is important.

    I got your email as I was writing this, help is on the way

  12. #12
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    why would I say "I tried this and that, and it didn't work." when I can put it a but more polite
    I guess we're talking about different things.
    I'm talking about information. Everyone should provide as much detail and relevant information as possible in order to get better and faster help.

    We expect everyone here to be polite, that's pretty obvious, and makes part of the rules of the forum.
    There are always exceptions, but usually, people who are helping, are supposed to be nice, and polite.

  13. #13
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Tried to email you but it bounced, so here are the steps you need to follow to be able to open a file without the ugly DOS box that appears when you normally do this from Flash...

    1. Create a BAT file called word1.bat that contains just the following line. This is just a simple text file that you create with notepad or your favorite plain text editor.

    start word1.doc

    2. Put the BAT file in a folder called fscommand along with a copy of proxy.exe (from http://www.northcode.com/misc/proxy.zip).

    3. Rename the copy of proxy.exe to word1.exe (same base name as the BAT file you created).

    4. Place your Word document (called word1.doc) in the fscommand folder with the BAT and EXE files. You don't have to store the files you want to open in the fscommand folder, but for your first test this makes things easier

    5. Add the following command to your FLA where you want to open the word document (probably on a button release action).

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

    Now put your Flash EXE and the fscommand folder on your desktop and run the Flash EXE. When the EXEC command is called your Word document should open.

    You will need one BAT file and one EXE file (renamed copy of proxy.exe) for every file you want to open from Flash. The reason for this is that Flash doesn't allow you to pass parameters using the EXEC command. It's a wee bit clunky, but it's FREE and it works.

  14. #14
    Member
    Join Date
    May 2006
    Location
    UK
    Posts
    92
    Northcode you a total pro!! thanks sooo much man got it working all lovely and smooth now. Learned a nice but of info from you that I can use again and again so thanks a lot!!

    And on the post you made before giving me the little tut what you said really did make sence to me and I was probably being a bit hastey. So I hand out my apologies to nunomira as I realise you were just trying to help me out, and due to me inexperiance on the forum I posted my thread in the wrong place. Anyways I hope there is no hard feelings guys and thanks again Northcode you the man!!!

    peace.

  15. #15
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    Every thing's fine with me.
    As long you got the help you were looking for, that's ok.


  16. #16
    Junior Member
    Join Date
    Jun 2000
    Posts
    7

    A Few Important Details

    Hi guys - I was able to use the info in this thread to create a Standalone executable with Flash5 that runs as an autorun splash screen from a CD. Thanks a whole lot, especially to NorthCode!

    However, I thought I should add a few things for future readers.

    1) Northcode wrote "Now put your Flash EXE and the fscommand folder on your desktop and run the Flash EXE. When the EXEC command is called your Word document should open." This isn't quite correct for Flash5. The Flash EXE needs to be inside the fscommand folder for it to work.

    2) If you want to open files from other folders outside the fscommand folder, this can be done fairly easily. Just type the relative path into your .bat file.

    Here's a sample file structure:

    ROOT
    __|__________
    | |
    [fscommand] [file_directory_1]

    Your Flash.exe file, word1.exe file, and word1.bat file are all inside the fscommand folder. The file_directory_1 folder contains your word documents. To open one of these - let's call it "my_word.doc" - from inside the fscommand folder, call word1.exe from your flash button. The corresponding word1.bat file should read:

    start ../file_directory_1/my_word.doc

    You can create as many .exe and corresponding .bat files as you need.

    Then just drop all your clunky .exe and .bat files inside the fscommand folder, while keeping Word documents, PDFs and whatnot in nice, neat contents folders.

    Wrap the whole thing up with an autostart in the root, tie it up with a cute little icon bow, and - Ta-Da! A professional-looking CD full of useful files with an autorun splash navigation window.

    Thanks again. I am a happy puppy.

  17. #17
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Actually... the whole "fscommand" folder (security sandbox) was first implemented by Macromedia in Flash MX (6) so before that you didn't need to worry about the fscommand folder at all.

    So, with Flash 5 (and earlier versions) you could put EXE and BAT files you wanted to EXEC just about anywhere.

    Much more information can be found at beyondflash.com. It's an old site that has some info about how to use EXEC with Flash 5 and explains the (then) new fscommand thing for Flash MX.

  18. #18
    Junior Member
    Join Date
    Apr 2008
    Posts
    4

    Problem with proxi.exe

    Hi, your proxi feature is just what I need (open a .doc from a flash projector) and I downloaded your zip file, but the included example does not work: both blue buttons do nothing. I tried also to build my "case" following your instructions, but, of course, with the same result as of your examples.
    Do I miss something?

    thank you very much
    piero

  19. #19
    Junior Member
    Join Date
    Apr 2008
    Posts
    4

    Proxi feature works well - Sorry

    Sorry, I read better the documentation on your web site and I discovered I have to put the file under the folder "fscommand".
    I apologize for my previous post.
    Piero

  20. #20
    Junior Member
    Join Date
    Jul 2008
    Posts
    5

    Question I am having some problems with this - PLEASE HELP!

    I am trying this with flash cs3 (saving/publishing in flash 8 format) and windows vista ultimate.

    My directory structure is:

    -Root folder-
    AC_RunActiveContent.js
    openword.fla
    fscommand
    openword.exe

    -fscommand-
    word1.bat
    word1.doc
    word1.exe


    my flash file contains one button in the first frame with the following code inside of it:
    on (release) {
    fscommand("exec", "word1.exe");
    }

    word1.bat contains the following code in the first line:
    start word1.doc


    i downloaded proxy.exe from northcodes link and renamed it to the word.exe and put it in the fscommand folder.

    what am I doing wrong???...this is really bothering me, could it be my flash players local settings??...if so how do i access/change the settings?...please 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