• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to embed pdf file in flash based android application

Explorer ,
Dec 17, 2012 Dec 17, 2012

Copy link to clipboard

Copied

Im trying to create android and iPad application using the flash CS 5. Facing some problem to open the PDF file using some button inside my application.

I have PDF file and I want, when I press some button then PDF file will open. I'm using this code

myPDF.addEventListener(MouseEvent.CLICK, ldr);

    function ldr(event:MouseEvent):void {       navigateToURL(new URLRequest("Dimensions.pdf"), "_blank"); }

this code is working properly in the computer but in android tablet I got this error message **“ERROR, the ducoment path is not valid”**

Note: (my flash file (application file) and PDF file is in the same folder in my computer)

Please suggest me how I can open the PDF file using the button inside of my application.

TOPICS
ActionScript

Views

12.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 03, 2013 Jan 03, 2013

for your button to work when pressed, you should use:

public class bpdf extends SimpleButton

                    {

                               public function bpdf()

                              {

                              // constructor code

                                       this.addEventListener(MouseEvent.MOUSE_DOWN,downF) ;  // import flash.events.MouseEvent

                              }

                                        private function downF(e:Event):void{

                   

...

Votes

Translate

Translate
Community Expert ,
Dec 31, 2012 Dec 31, 2012

Copy link to clipboard

Copied

use:

public class bpdf extends SimpleButton

                    {

                               public function bpdf()

                              {

                              // constructor code

                                        this.addEventListener(Event.ADDED_TO_STAGE,initF) ;

                              }

                                         private function initF(e:Event):void{

                                                  var htm:HTMLLoader= new HTMLLoader();

                                                  htm.load(new URLRequest("test.pdf"));

this.parent.addChild(htm);

                                                  // create a close button for htm and add it (to this.parent) and its listener here

                                                  }

                                                            function onCloseEvent(e:Event)

                                                            {

                                                                      trace("window closed");

                                                            }

                              }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 01, 2013 Jan 01, 2013

Copy link to clipboard

Copied

no error but when i check this in may taplet (.APK) link is not working

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 02, 2013 Jan 02, 2013

Copy link to clipboard

Copied

you have to set the width and height:

public class bpdf extends SimpleButton

                    {

                               public function bpdf()

                              {

                              // constructor code

                                        this.addEventListener(Event.ADDED_TO_STAGE,initF) ;

                              }

                                         private function initF(e:Event):void{

                                                  var htm:HTMLLoader= new HTMLLoader();

                                                  htm.load(new URLRequest("test.pdf"));

htm.width=stage.stageWidth;

htm.height=stage.stageHeight;

this.parent.addChild(htm);

                                                  // create a close button for htm and add it (to this.parent) and its listener here

                                                  }

                                                            function onCloseEvent(e:Event)

                                                            {

                                                                      trace("window closed");

                                                            }

                              }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 02, 2013 Jan 02, 2013

Copy link to clipboard

Copied

I appreciate your effort. Facing same problem, no error but nothing happened

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 02, 2013 Jan 02, 2013

Copy link to clipboard

Copied

does it work when you test?

if yes, did you add test.pdf to your included files?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 02, 2013 Jan 02, 2013

Copy link to clipboard

Copied

Yes application is working but link is not working. When I press the button nothing happened

I include the test.pdf file as well

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2013 Jan 03, 2013

Copy link to clipboard

Copied

nothing is coded to happen when the button is clicked.  your pdf is coded to load when bpdf is added to the stage.

is that what you see when you test?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 03, 2013 Jan 03, 2013

Copy link to clipboard

Copied

I mean to say, publishing time I didn’t get any error (Android Player - .apk). but after publishing (.apk file) when I check this file in my tablet, button link is not working.

When I click on the button, PDF file have to open but it’s not opening.

(I include my pdf file)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2013 Jan 03, 2013

Copy link to clipboard

Copied

for your button to work when pressed, you should use:

public class bpdf extends SimpleButton

                    {

                               public function bpdf()

                              {

                              // constructor code

                                       this.addEventListener(MouseEvent.MOUSE_DOWN,downF) ;  // import flash.events.MouseEvent

                              }

                                        private function downF(e:Event):void{

                                                  var htm:HTMLLoader= new HTMLLoader();

                                                  htm.load(new URLRequest("test.pdf"));

htm.width=stage.stageWidth;

htm.height=stage.stageHeight;

this.parent.addChild(htm);

                                                  // create a close button for htm and add it (to this.parent) and its listener here

                                                  }

                                                            function onCloseEvent(e:Event)

                                                            {

                                                                      trace("window closed");

                                                            }

                              }

///////////////////////////////////

test this in the ide and confirm that your pdf is being loaded and displayed before testing on your android device.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 05, 2013 Jan 05, 2013

Copy link to clipboard

Copied

Facing same problem in my PC and Android Device

When I publish the file, didn’t get any output or compiler errors

I check this file in my PC (.swf), when I click on the button, nothing happen (PDF file is not opening)

Also after installing this app (.apk) in my android device, nothing happened when I click on the button.  Still pdf file is not opening

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 05, 2013 Jan 05, 2013

Copy link to clipboard

Copied

put a trace("HI") in the constructor of bpdf and test.  do you see HI traced in the output panel?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 05, 2013 Jan 05, 2013

Copy link to clipboard

Copied

i try this but......  Facing same problem in my PC and Android Device

in output panel i got this message

[SWF] link9.swf - 2784 bytes after decompression

[UnloadSWF] link9.swf

Test Movie terminated.

package

{

          import flash.html.HTMLLoader;

          import flash.net.URLRequest;

          import flash.display.NativeWindowInitOptions;

          import flash.display.NativeWindowSystemChrome;

          import flash.display.NativeWindowType;

          import flash.display.NativeWindow;

          import flash.events.Event;

          import flash.events.MouseEvent;

          import flash.display.SimpleButton;

          public class bpdf extends SimpleButton

          {

                    public function bpdf()

                    {

                    // constructor code

                              this.addEventListener(MouseEvent.MOUSE_DOWN,downF) ;  // import flash.events.MouseEvent

                    }

                    private function downF(e:Event):void{

                              var htm:HTMLLoader= new HTMLLoader();

                              htm.load(new URLRequest("test.pdf"));

                              htm.width=stage.stageWidth;

                              htm.height=stage.stageHeight;

                              this.parent.addChild(htm);

                              // create a close button for htm and add it (to this.parent) and its listener here

                    }

                    function onCloseEvent(e:Event)

                    {

                              trace("HI");

                    }

          }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 06, 2013 Jan 06, 2013

Copy link to clipboard

Copied

use the following code.  do you see HI in the output panel when you test in flash?

package

{

          import flash.html.HTMLLoader;

          import flash.net.URLRequest;

          import flash.display.NativeWindowInitOptions;

          import flash.display.NativeWindowSystemChrome;

          import flash.display.NativeWindowType;

          import flash.display.NativeWindow;

          import flash.events.Event;

          import flash.events.MouseEvent;

          import flash.display.SimpleButton;

          public class bpdf extends SimpleButton

          {

                    public function bpdf()

                    {

                    // constructor code

trace("HI");

                              this.addEventListener(MouseEvent.MOUSE_DOWN,downF) ;  // import flash.events.MouseEvent

                    }

                    private function downF(e:Event):void{

                              var htm:HTMLLoader= new HTMLLoader();

                              htm.load(new URLRequest("test.pdf"));

                              htm.width=stage.stageWidth;

                              htm.height=stage.stageHeight;

                              this.parent.addChild(htm);

                              // create a close button for htm and add it (to this.parent) and its listener here

                    }

                    function onCloseEvent(e:Event)

                    {

         

                    }

          }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2013 Jan 06, 2013

Copy link to clipboard

Copied

yes i see HI in output panel but problem is still same (not working)

01.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 06, 2013 Jan 06, 2013

Copy link to clipboard

Copied

attach a screenshot that shows the files in your flash working directory.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2013 Jan 06, 2013

Copy link to clipboard

Copied

you mean this

02.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2013 Jan 09, 2013

Copy link to clipboard

Copied

boss any suggestion??

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2013 Jan 09, 2013

Copy link to clipboard

Copied

i can't see where your error is.

but here's exactly the same code working without problem:  http://www.kglad.com/Files/forums/test_pdf.zip

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2013 Jan 09, 2013

Copy link to clipboard

Copied

can u give me this file in FLASH CS5.5

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2013 Jan 09, 2013

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 11, 2013 Jan 11, 2013

Copy link to clipboard

Copied

its working boss in PC but when i publish this file in android device and IPad device, pdf file not open

also when i open the file in FLASH CS6 i got this message

01.jpg

Is this problem come for SDK?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 11, 2013 Jan 11, 2013

Copy link to clipboard

Copied

1.  why wasn't the same code working in your test?

2.  test if your android device supports htmlloader by using the following in the bpdf constructor (ie, where the trace statement was):

if(!HTMLLoader.isSupported){

this.alpha=.1;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 15, 2013 Jan 15, 2013

Copy link to clipboard

Copied

you mean like this

package {

          import flash.display.SimpleButton;

          import flash.events.MouseEvent;

          import flash.events.Event;

          import flash.html.HTMLLoader;

          import flash.net.URLRequest;

          public class bpdf extends SimpleButton {

 

                    public function bpdf() {

                              // constructor code

                               this.addEventListener(MouseEvent.MOUSE_DOWN,downF) ;

                    }

                    private function downF(e:Event):void {

                              var htm:HTMLLoader= new HTMLLoader();

                              htm.load(new URLRequest("test.pdf"));

                              htm.width=300;

                              htm.height=300

                              this.parent.addChild(htm);

                              // create a close button for htm and add it (to this.parent) and its listener here

                    }

                    function onCloseEvent(e:Event) {

                              trace("window closed");

                              if(!HTMLLoader.isSupported){

                              this.alpha=.1;

                              }

                    }

          }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 15, 2013 Jan 15, 2013

Copy link to clipboard

Copied

Do you have some solution for this as well?

http://forums.adobe.com/thread/1135510


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 12, 2013 Mar 12, 2013

Copy link to clipboard

Copied

LATEST

When i was starting my career in iPhone application development, i am also facing the same issue then i contact with same professional android application development company to fix this issue permanently

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines