dcsimg
A Flash Developer Resource Site

Results 1 to 20 of 22

Thread: Open PDF and Files with AS3 from projector

Hybrid View

  1. #1
    Senior Member
    Join Date
    Aug 2001
    Location
    New York City
    Posts
    409

    Open PDF and Files with AS3 from projector

    Hi -

    I have used M-Projector, North Code, and ZINC in the past, but I haven't had the need to create a standalone in a while. Since then CS4 and AS3 and I tried using the old fire-it-up which allows you to launch, print and save files. It works in AS2 but not my AS3 project.

    Does anyone have a simple Cross Platform suggestion ? All I want to do it Launch Files and Keep it simple. I don't really want to have to learn an API from some of the great 3rd party tools out there.

    Any Suggestions to perform this simple task ?
    Thanks!

  2. #2
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766

  3. #3
    Senior Member
    Join Date
    Aug 2001
    Location
    New York City
    Posts
    409
    Thanks NorthCode !
    I actually remember this thread from a while back. I will use it now since this is all I want to do.

    However... Will this work using AS3 ?

  4. #4
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    The EXEC fscommand works in all versions of Flash as long as you're creating a projector (it won't work from a SWF).

  5. #5
    Senior Member
    Join Date
    Aug 2001
    Location
    New York City
    Posts
    409
    Hi NorthCode -
    I tried the PROXY and the BAT File recipe as you suggested and it's not opening a file. Here's what my file structure looks like:
    FScommand (folder)
    - invoke.exe
    - launchTest.BAT
    - launchTest.exe


    Outside of the FScommand folder I have this:
    files (folder)
    launchtest.pdf

    And this :
    launchAS3.exe (The Projector File)

    inside my BAT file I have this line:

    invoke.exe open \files\launchTest.pdf

    And I just changed the name of the PROXY.EXE to:
    launchTest.exe

    Anything else I can do ? I uploaded my .fla and the files, without the Projector (or it would have been to large for FlashKit) Maybe you can take a look or a test? thanks so much.
    Attached Files Attached Files

  6. #6
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Your problem isn't with proxy, invoke or your BAT file. If you put a trace statement in the launch() function you'll see that it isn't getting called! That's the problem.

  7. #7
    Senior Member
    Join Date
    Aug 2001
    Location
    New York City
    Posts
    409
    Hi Northcode -

    I feel like I am close to this working. Here's my AS3 code and it DOES CALL THE function and a trace:
    Code:
    function launch(event:MouseEvent):void {
    
    	fscommand("exec", "launchTest.exe");
    	trace("I am calling the function now");
    
    }
    launchButton.addEventListener(MouseEvent.CLICK, launch);
    
    launchButton.buttonMode=true;
    Am I calling the calling file ? Not sure, but the function seems to be working... any other suggestions? Thank you so much for your help

  8. #8
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Odd, when I published your FLA to an EXE last time it didn't work, now it does. I replaced what you had with the latest versions of invoke.exe and proxy.exe and changed the path in the BAT file from \files\launchTest.pdf to ..\files\launchTest.pdf and it's working fine for me. If you grab steve1312_proxy2.zip (2.34 MB) I've included everything, including a compiler version of launchAS3.exe.

  9. #9
    Senior Member
    Join Date
    Aug 2001
    Location
    New York City
    Posts
    409
    Thanks Northcode. Works like a charm !
    You are a master ! thank you.

  10. #10
    Registered User
    Join Date
    Apr 2011
    Posts
    2
    Hi Tim,

    Do you have any idea how to handle the document (doc, pdf, etc) in MAC OS (intel based MAC OS 10.5 or above)?
    We are using the getURL and placed the document fscommand folder. Some MAC machines not opening the documents.
    I am using flash player 9.0 projector file.
    Please help.

  11. #11
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    AppleScript is the simplest solution for the Mac and you can basically do the same thing. Create one AppleScript for each file you want to open and then use fsommand("exec", "file1.app") where file1.app is a compiled AppleScript that opens a PDF file.

    The key difference between OSX and Windows is where the fscommand folder goes. On windows it goes in the same folder as your EXE. On OSX it has to be put inside the projector's application bundle in MyApp.app -> Contents -> MacOS, which is where the Flash player binary actually lives.
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  12. #12
    Junior Member
    Join Date
    Mar 2012
    Posts
    1
    thx Tim , you're the man

  13. #13
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930
    NC,

    I'm working on a hybrid cd (and web) project and have the getURL working on the web-side, the bat files working on the PC side and just need to get the applescript files compiled. Do you know of any way to do this on a PC?

    Also, what is the correct syntax within the applescript file? If I have to send it to my client to compile on his Mac, I'd like to only have to do it once.

    Do I have it call the Word file directly:
    Code:
    tell application "Microsoft Word"
        activate
        open "DNALab.doc"
    end tell
    Save this as DNALab.app and have as3 call:
    Code:
    fscommand("exec", "DNALab.app");
    Thanks!
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  14. #14
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    As far as I know there's no way to compile an AppleScript from a PC, you'll need a Mac to do that.

    If you know where the file is going to be on the CD and you can set the CD name then you can use a simple script like this one.

    Code:
    tell application "Finder"
       activate
       select file "file.doc" of folder "fscommand" of disk "CDNAME"
       open selection
    end tell
    If you can't control any of that, then you have to resort to something a little more complicated that locates the file you want to open from a location relative to your application. I've posted this before, but I'll save you the trouble of hunting it down.

    Code:
    --set the name of the file to open 
    
    property fileName : "homepage.html"
    
    --get the path to the containing folder 
    
    set myPath to (path to me as string)
    set AppleScript's text item delimiters to ":"
    
    set the parentFolder to 
    	((text items 1 thru -2 of myPath) & "") as string
    
    set AppleScript's text item delimiters to ""
    
    -- find the flash file 
    
    try
    	set targetFile to alias (the parentFolder & fileName)
    on error
    	--ie if there's no  file here by this name, it will quit. 
    	return quit
    end try
    
    -- open the file 
    
    tell application "Finder"
    	open file targetFile
    end tell
    If you're using CS3 (or newer) you need to know that the FSCommand folder is now INSIDE your .app file and not an external folder as it was in versions before that. This makes targeting files from AppleScript a little trickier because every reference you make is relative to the fscommand folder, where the AppliScript has to be so you can EXEC it.
    Last edited by Northcode; 07-03-2012 at 03:42 AM.
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  15. #15
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930
    Cool, I got a buddy with a mac to make the scpt files for me. I published the Mac projector and am getting ready to send it to the client to review. Do I have to drop the fscommand folder inside the start.app folder or the Contents folder?

    Thanks!
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  16. #16
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Sorry, I was awa last week... Did you get this sorted out?
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  17. #17
    Space Monkey daarboven's Avatar
    Join Date
    Sep 2001
    Location
    in the basement boiling soap...
    Posts
    217
    Sorry to dig out this old thread but I banged my head on this the whole morning so I thought I'd share my solution to help you out maybe:

    As a long time user of proxy.exe I went to open a bunch of pdfs with .bat and proxy as usual - just to be stomped this time by the whole thing not working...All i get is silence. Testing the renamed proxy with clicking works, FlashPlayer refuses to open my pdf >
    So I dug out an old project of what I knew was working and entered my new path in the bat: Tadah, runs shmooz!
    Renamed the bat and exe to resemble the pdf name and the whole thing facepalmed again-wtf!
    Not to torture you any longer heres the solution:
    The filename , hence the name of the bat and the exe now contained a "-" character causing the failed exec command. soon as I removed that from both the exe and bat names I was golden again. the filename inside the bat still contains this infamous little character but that doesn't seem to be a showstopper...
    :::i am jacks complete lack of surprise:::

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