|
-
Product Designer
Open a PDF from a projector (on MacOS)
I have used BAT files to open PDF documents from within a Flash Projector (as described in another post in this forum), on Windows.
But how do I do so on a Mac?
I want to deploy a hybrid CD, but for now the Mac side has only 80% of the features (it lacks opening the attached PDF documents from within the movie, and it lacks AUTOPLAY, which apparently is not available on MacOS....).
Altruism does not exist. Sustainability must be made profitable.
-
Lifetime Friend of Site Staff
The MAC has AutoPlay but it's part of QuickTime. There's no guarantee on either platform that AutoPlay will be enabled. On the PC it's enabled by default, on the MAC it's disabled by default.
I've posted this function here a few times, it may simplify your job of opening PDF files a bit. Instead of calling fscommad "exec" everywhere you want to open a file and worrying about which platform you're on, you replace those calls with calls to SmartExec.
Code:
function SmartExec(target)
{
platform = substring(getVersion(), 1,3);
if (platform == "WIN")
{
// we're running on Windows, target an EXE file
fscommand("exec", target + ".exe");
}
else
{
// we're running on a MAC, target an AppleScript file
fscommand("exec", target + "_script");
}
}
EXEC only works with executable files. In Windows that means EXE, COM and BAT files. On the MAC that's applescripts, applications and probably some other stuff I'm unaware of 
The trick to making this work in Windows is to write a BAT file called "thefile.bat" that has the command you need to open your PDF file (like "start thefile.pdf") then rename my proxy.exe utility to thefile.exe and call that using the SmartExec function like this: SmartExec("thefile").
For the MAC, you just create an applescript called thefile_script with the commands to open the PDF file and the same call to SmartExec will get the job done on either platform.
All the executable files, BAT files, AppleScripts go in the FSCommand folder. The files you want to open can go in there too if you want to make writing the scripts and BAT files easier on yourself.
You might want to check out Conquering-FSCommand EXEC Part-1 : Proxy for a FREE utility I wrote that will let you run BAT files from Flash and avoid the ugly DOS box. There was a big discussion about it (and some other utilities I wrote) in http://www.flashkit.com/board/showth...hreadid=519274.
-
Product Designer
Thanks Northcode, I have already implemented your solution (including the proxy).
My question was more about a Mac-specific code (either Applescript or whatever else would work) to trigger the opening of the file.
Thanks for the info
Altruism does not exist. Sustainability must be made profitable.
-
Lifetime Friend of Site Staff
Here's an example AppleScript to open a file called "thefile.pdf" that exists in the same folder as the script.
Code:
--set the name of the file to open
property fileName : "thefile.pdf"
--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
-
Hey,
Sorry to hijack this thread, but I'm looking for some insight on AppleScript's and I haven't got any luck.
Northcode, using your Applescript example what should I change if the file (pdf) would be in the same folder as the _script?
-
Lifetime Friend of Site Staff
The parentFolder is created by stripping components off myPath until we get to the parent folder. Just change that to strip off the script name (instead of the script name and the current folder) like this...
set the parentFolder to ¬
((text items 1 thru -1 of myPath) & "") as string
And "parentFolder" now points to the script folder. You can rename the parentFolder variable to something more accurate if you like clean code, but it will still work if you don't
-
So this change is enough ?!?
Thanks for the reply Northcode
-
Lifetime Friend of Site Staff
Untested, but that should do the trick.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|