In this example file there are 2 buttons
By clicking first button a dos prompt window open and by clicking 2nd button dos prompt window open just for a moment.
check it out
BUT FIRST OPEN THE .fla FILE AND MAKE .exe FIle THROUGH PUBLISH SETTINGS AND PLACE THAT PROJECTOR FILE IN EXAMPLE FOLDER THEN RUN THAT FILE
In this example file there are 2 buttons
By clicking first button a dos prompt window open and by clicking 2nd button dos prompt window open just for a moment.
check it out
BUT FIRST OPEN THE .fla FILE AND MAKE .exe FIle THROUGH PUBLISH SETTINGS AND PLACE THAT PROJECTOR FILE IN EXAMPLE FOLDER THEN RUN THAT FILE
Wierd. I got this Northcode solution working for my own project, but I can't get yours to work. In fact, I couldn't even get the batch file to run by itself, until I renamed the file back to include the .bat extension visually in the XP explorer window.
In the second example you posted both buttons work fine for me. That's on a Windows 2000 system with Flash MX 2004 (7.2) and Acrobat Reader version 6 installed.
If you add a PAUSE statement at the end of your BAT files that will keep the DOS window open so you can see any errors that might be displayed too quickly for you to see.
Also, just FYI, You don't need the EXIT at the end of the BAT file. If you keep the EXIT command, make sure the PAUSE appears first or the window will close before it gets to the PAUSE statement.
it is also working in window XP on my computer adn i have checked it on other computers also.
Mr. Northcode u r talking about PAUSE statement can u explain it more because i'm little bit confused.
Mr.Scott what u r saying i cant understand can u reply me again that what u r saying.
OK, that last file that you posted works fine for me on XP, now, too. I was trying to run it from a network folder and I believe .bat file didn't like that. I got this 'UNC paths are not valid/allowed' warning.
PAUSE is just another command you can use in a BAT file. It pauses the BAT file until you press a key and gives you a chance to look at the output before it disappears. Just put PAUSE on a line by itself in the BAT file. You'll want to remove it from the finished product though, it's just for testing.
I used your code to great succes - thanks for the generous help! I'm curious though if it's possible to have the code work dynamically, so that one does not have to create pdf1.exe, pdf2.exe, pdf3.exe, etc. My current project has about 40 pdf links and a dynamic capability would seem to be a much less cumbersome way to go.
I am also trying to figure this out but rather than send you more files to look at would it just be possible for you to post like a mini project.
you know just something super simple that launched a single pdf file from a button action. If you could post that with all necessary scripts .bat .exe and proper file structure. I think that would be the most beneficial to alot of us here and may stop the need to constantly ask you to look at our files.
If we can see 1 example fully realised I think it owuld be safe to assume that we should beable to figure out how to add extra pdfs.
I actually just posted step-by-step instructions for doing this for jujumon in this thread http://www.flashkit.com/board/showthread.php?t=660265 (here in the standalone & applications forum) along with an FLA in MX 2004 format (let me know if you need it in MX or something) and all of the other required files
To answer incubox's question... To do this dynamically you would need to be able to pass parameters to the EXE file, which is what Macromedia changed in MX. You can't pass parameters to applications via the EXEC command any more.
If you're willing to shell out some bucks then you can pick up one of the many third party swf2exe applications. These tools extend what you can do from Flash and they DO allow you to pass parameters to EXE files and most of them have special commands that allow you to open PDF files and such directly.
In my product, SWF Studio, you can just say ssCore.Shell.invoke({path:"startdir://file1.pdf"}) to open the PDF file in Acrobat Reader (or whatever PDF viewer the user has installed). Because you don't need an external helper EXE you can just open the PDF files by name. Our syntax may look a bit foreign at first, it's out very own ActionScript API and it provides a powerful and convenient way to access our extended functionality from Flash.
Northcode -
I followed your step by step instructions and it works like a charm! Thank You.
Since this thread is old, I wasn't sure if there were any updates to this in regards to applying this to multiple PDFs. I have aprox 200 PDFs to apply this functionality to for CD delivery.
You mentioned using SWF Studio to dynamically make this happen. I downloaded a trial version to check it out, but am clueless on how to achieve this.
Can you guide me in the right direction?
If the PDF file names have a structured naming convention (file1.pdf, file2.pdf, etc) then you can just construct the file name that you're passing Shell.invoke like this...
But how you do it will depend on how you're trying to launch the PDF files. Is the user selecting a file from a list? browsing the filesystem? selecting from 1 ot 200 buttons?
If you can provide more detail about the mechanism you're using for selecting the PDF to be launched I can be more specific.
The print button is calling PDFs dynamically using a getUrl call and the button is not on stage. The PDFs are not using a structured naming convention (file1.pdf, file2.pdf, etc), nor are they all in the same directory.
I'd like to send the .fla in question to you directly, if possible. (Would prefer to not post client file here).
Thank you!
Thanks Northcode for your proxy solution it worked great and your excellent posts have been extremely helpful to me so far. I know this subject has been rehashed a bit but I'm having trouble with opening a pdf on a Mac projector developed on a PC.
Firstly, I made the Applescript on a borrowed Mac (OS X 10.5.5) which works as it should. Then I zipped it up (on the Mac) send it to myself and via email (don't unzip) and use CD Everywhere to add from zip archive to burn a hybrid CD. When I run the Mac projector on the borrowed Mac it doesn't work and looking on the disk it seems the script may be damaged because when I click it is says "classic environment not supported" and the icon is different from the original.
For those who are successful in making a hybrid CD how are you getting the script to your PC without breaking it? Or is it something else I'm missing?
I have an fscommand folder with the PDF and script in it.
My button code is:
Code:
on (release){
var os:String = System.capabilities.os.substr(0, 3);
if (os == "Win") {
fscommand ("exec","74547_CH010_lecture.exe");
} else if (os == "Mac") {
fscommand ("exec","74547_CH010_lecture.app");
} else {
// Must be Unix or Linux
}
}
Alrighty then finally after tons of hair pulling it's working, and here is what I did to get PDF's to launch on a hybrid CD from a Mac projector.
I'll just include what I did for the Mac (OS X 10.5.5) as Northcode's Proxy solution is the only way to go for the PC side of things.
- First create an Applescript. This one worked for me. Tip: If you have your CD laid out already but have not got the scripts written, you can go into the script editor and record your actions opening the PDF to get a script that is for sure to work. After creating the script with your CD still in the Mac double click the script to try it out.
Code:
tell application "Finder"
activate
select file"74547_CH010_lecture.pdf" of folder"fscommand"of disk"LectureCD"
open selection
end tell
save as an application and you will have "yourPDF.app" or in my case 74547_CH010_lecture.app
- I used fscommand as my folder and I believe you have to put your PDF's and script in this folder or it won't work.
- I used the button code here (change it to suit your files)
Code:
on (release){
var os:String = System.capabilities.os.substr(0, 3);
if (os == "Win") {
fscommand ("exec","74547_CH010_lecture.exe");
} else if (os == "Mac") {
fscommand ("exec","74547_CH010_lecture.app");
} else {
// Must be Unix or Linux
}
}
- Since I was developing on a PC and just writing the scripts on a Mac the biggest challenge which I had to find out the hard way, was that you CANNOT just zip it up and email yourself the .app script and burn it to CD as it breaks the script (probably resource forks).
I bought CD Everywhere Pro and tried to burn with the "get from ZIP Archive" thinking that will preserve the forks but that did not work.
You have to TAR it up on the Mac (I used TarPit, it's free) and that preserves the resource forks, then it is a simple matter in CD Everywhere to use the "get from TAR Archive" feature to include it in your project. I used CD Everywhere because it will decode the TAR file on the fly and the .app never touches the PC thus preserving it. CD Everywhere is expensive but it works. (not a paid endorsement) It seems that .ZIP doesn't preserve the file properly but .TAR does.
- Create image file (.iso) and burn
The biggest problem was getting that script over to the PC and burning it, but once that was solved it was easy-peasy
Time to buck up on my AS3 and move on to Adobe Air...
I am new to Flash, I have a project that will be a standalone CD to retreive pdf files.
I have read all the posts in this discussion and they seem to all refer to new versions of Flash ( after ver. 5). I am using Flash 5, and the problem is getting the pdf file to open with a button.
Do I need to use the .bat files with this old of a version?
Can I make this work with this older version?
This cd will only be used in PC not Mac if this matters.
I have tried using the getURL and it just opens a blank explorer page.