Skip to main content
Inspiring
December 18, 2012
Answered

how to embed pdf file in flash based android application

  • December 18, 2012
  • 1 reply
  • 13916 views

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.

This topic has been closed for replies.
Correct answer kglad

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)


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.

1 reply

kiran1989
Inspiring
December 19, 2012

You can use HTMLLoader class for loading pdf in your applicaiton or File and FileStream classes opening pdf files. These classes are available in air

Regards

kiran

71081Author
Inspiring
December 19, 2012

Im the new in AS3, can you plz give me the code

kiran1989
Inspiring
December 19, 2012

here is the code

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;

var htm:HTMLLoader= new HTMLLoader();

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

var init:NativeWindowInitOptions= new NativeWindowInitOptions();

init.systemChrome= NativeWindowSystemChrome.STANDARD;

init.type= NativeWindowType.NORMAL;

var win:NativeWindow= new NativeWindow(init);

win.stage.addChild(htm);

win.width=stage.stageWidth;

win.height= stage.stageHeight;

win.activate();

htm.width= win.width;

htm.height=win.height;

win.addEventListener(Event.CLOSE, onCloseEvent);

function onCloseEvent(e:Event){

 

          trace("window closed");

 

          }