How To Open PDF File From Flash using Fscommand

Filed Under: Articles, Tip and Tutor by fandy February 23, 2011, 16:56

open_pdf_from_flash

In last two weeks ago, I have case on my Flash project, using Flash CS5 with Action Script 3.0. I am creating a Flash application of a application tutorials to work on a CD. There is a manual documentation file in PDF format which the user can open the Pdf file.

The PDF file must be open in a separate, stand alone, not inside the flash or internet explorer. In this post I want to share who we can open the psf file in separate window with fscommand!

1. Write this Action Script, here’s my button instance name is "openPdf", and "manual.bat" is the file name of Batch file we want to call to open/execution the pdf file.

openPdf.addEventListener
    (MouseEvent.CLICK,
    function ():void
{
    fscommand ("exec", "manual.bat");

}
);

2. Create new folder the name is must "fscommand".

3. Copy the pdf file in folder /fscommand/

4. Open text editing tool, such as Notepad or Notepad++, create new one and type this codes

@echo off
start name_of_pdf_file.pdf

5. Save the text file as "manual.bat" or any name you like as same as the action script in our flash save it inside /fscommand folder.

6. Publish the Flash Document in Windows Projector (.exe). It would not running properly in swf movie file.

That’s it, but if you have better idea please put it in comment form

 

Updated!

you can download the example project file below.

AttachmentSizeHitsdescription
openPdf_example 2.55MB 2064 Example project file
click the attachment link to download the file


Written by fandy

a web and graphic designer whose love art and design and like to share knowledge, resources and inspirations. English not my mother language so don't blame me, I just do the best to sharing, just give me suggestion to fix it. If love my work, you can support me and follow me on Twitter


Share This :


I PROUDLY PRESENT

YOUR COMMENTS! I LOVE 'EM

deny says March 3, 2011,16:07

hy,,
I’ve try your solution , but it’s still doesn’t work though I’ve publish it in .exe file
please give me solution for this one , if you’re available, please send me an email
thanks a lot

    fandy says March 3, 2011,16:43

    @Deny; Are you get some error? if so let me know what error?
    The key are ‘fscommand’ folder where the .pdf file and .bat placed.

deny says March 4, 2011,07:22

@fandy , no , I’m not got some eror, but even I running that, it’s not work anymore , I mean it’s not call the .pdf file , just click click and nothing happen,
eh, may I know your facebook account? so we can tall more easy ,

deny says March 4, 2011,07:27

@fandy , may I know your facebook account, so we can talk more easy,
I’m not got some eror , but even I click , nothing happen I mean that button not call file .pdf that I will, :(
please help me ….

    fandy says March 4, 2011,07:36

    @deny, let me know your source project? send it to my email

deny says March 4, 2011,07:40

what is your email?

    fandy says March 4, 2011,09:59

    I sent you the email. But, I have update this post, you can download the example!

deny says March 4, 2011,13:53

oh,okay, thanks a lot for your help
hmm… are you indonesian people? because you had send me an email with indonesian language ..
I’m indonesian people

deny says March 4, 2011,14:01

is the scrip must in other layer of the button?
sorry I’m new in flash, hehe
with no teacher no book, just with application and internet

    fandy says March 4, 2011,14:59

    @Deny, The srcipt can be in other layer but on same timeline.
    Indonesian? Yes I’m asli 100% :)

deny says March 4, 2011,15:08

here i got some trouble,
in your sample, i see there is 2 frame, first frame is action and the second frame is for the button
when i see the action frame, i got your scrip, so i confused with this one, i mean about the action frame,
I sorry that i to much ask you
hope you will help me :)

deny says March 4, 2011,15:43

my friend,
I’ve new problem
I try to make flash send an email with a form,
the way that I’ve do is connect the flash to dreamwaver and the DW will send the email
but it’s no work propely,
can you give me solution for this?another way maybe for sen an email with flahs?
thanks a lot

deny says March 7, 2011,10:04

hy bro,
help me for this one to
I will make make project fit to all screen, I mean when my client open it, my flash automatic fit to all screen size,
how to make it real?
thanks a lot

    fandy says March 7, 2011,15:04

    Add this script on first frame
    fscommand(“fullscreen”, “true”);

deny says March 8, 2011,08:45

bro,
how to call a frame in one timeline?
need help.

Brett Widmann says May 7, 2011,05:25

This was really helpful! Thank you.

Florian says August 5, 2011,09:39

Hi!
thanks for your example! you think it is possible to pass a parameter from flash to the bat file? for example to open different urls?
how would you implement the bat solution on mac?

do you know perhaps also other ways to open files or folders from flash player? many thanks,
florian

jucelin says August 23, 2011,09:24

Thanks for your example, but I have a question, how can I open a PDF document in flash player when we use it to show PDF document in my website? It just like http://docs.google.com/viewer.

collen says August 28, 2011,19:01

How do you open a pdf file using a TLF TEXT link? is this possible?

Xtian says October 19, 2011,07:25

Hello… I would like to open a new swf from another swf. But i don´t want to open it inside the original swf, but in a new “swf window”… so when i click in the button in the original swf, a new swf appear, without desapearing the original swf. I hope you understand to me. Please help. Thanks.

    fandy says October 19, 2011,10:14

    Hi Xtian, you can use this code “getURL(“myMovie.swf”,”_blank”);” it will open in new window

lytos says November 17, 2011,05:53

Gracias. Muy útil la imformación….

serviover says November 19, 2011,10:31

hey fandy,
I tried more time to do this. But still I can’t open my pdf and also ur example project can’t open Adobe flash cs3. what can I do???

Heather Cheek says January 11, 2012,02:11

This worked BEAUTIFULLY for me. I was very lucky to find this as I spent half of my day trying to figure this out in CS5. I’m currently trying this method to open file folders.

Ren says January 31, 2012,02:58

This was very helpful and saved me a lot of trouble!

I have a question:
Can you use this method multiple times in a single application? There are two things I need to open up, and using your method would work very well, but I tried to make a separate .bat file and both links stopped working. I may have done something wrong.

    fandy says January 31, 2012,11:49

    @Ren, you can use this method multiple times with make multiple .bat files, in each button call different .bat file (ie. manual.bat, manual01.bat, manual02.bat) and each call different pdf.

amir says February 24, 2012,23:06

Thanks man. It’s very useful for me :)

Masoud says March 11, 2012,21:24

Hi Fendy, When I open a PDF with Fscommand and BAT, I can see CMD window. How can I hide that?
Pleas answer me by email. I don’t use internet too much!

Ting says March 15, 2012,16:30

Hi Fandy,

I am using Flash CS5 on macintosh. Will you be able to show me what is the complete script for opening PDF with macintosh Flash CS5?

Thanks.

Noylin says April 17, 2012,12:53

Thanks a lot!!! It’s the very thing I need!

Anand says May 3, 2012,17:54

The Script is totally correct there is no errors in it what i am able 2 notice is that it works great when u publish it . The flash exe output works perfect the SWF has probs.

LEAVE A COMMENT

AND MAKE ME HAPPY

Your email address will not be published. Required fields are marked *

Name*

Email*

Website

Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Our Sponsors

Community News

    • How to delete facebook account

      Setup by Setup guide and tutorial on how to delete facebook account.

    • 10 Useful Photoshop Web Design Layout Tutorials

      In todays post I’ve collected 10 tutorials about creating a website layout in Photoshop. These tutorials cover different types of web design and hopefully will teach you some new tricks and techniques.

    • Designing with Black: Techniques on How to Create this Artwork

      Art covers a diverse range of human activities and using black as an artwork often applies to visual art such as painting, fashion and photography. Here we share some techniques on how to create artworks using black.

    • 30 Stunning Examples of Grayscale Portrait Photography

      A photographers ability to understand and use the light, literally makes or breaks portrait photography. Understanding the subject and his/her pose also do world of good for a photographer. The face and expression of the subject are of utmost importance when taking a portrait. Grayscale photography mostly known as black-and-white photography is mainly composed of shades of gray. Many a times Grayscale are also known as monochromatic photographs because of the presence of one color in the image.

    • 25 Best Colorful Patterns for Your Next Design

      Default Adobe Patterns are not always successful in satisfying every designer need. Sometimes designers need something different, something which is not very common and yet exactly goes with the designer’s work.


    SUBMIT LINK | MORE NEWS

Recent Comments

    • Saya : I will use them and sponsor them in my blog because their cr... more
    • APNA JAHANIAN : will you please recommend any best software to design brochu... more
    • Samuel : High quality large images are always a plus and can add a lo... more
    • Saya : Nice collection thanks... more
    • APNA JAHANIAN : all themes are great and professional look.specially daily p... more
Hookahs F50-531 st0-096 Dedicated Servers Web Hosting

Twitter: ArtfanDesign