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.
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{
...
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");
}
}
Copy link to clipboard
Copied
no error but when i check this in may taplet (.APK) link is not working
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");
}
}
Copy link to clipboard
Copied
I appreciate your effort. Facing same problem, no error but nothing happened
Copy link to clipboard
Copied
does it work when you test?
if yes, did you add test.pdf to your included files?
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
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?
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)
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.
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
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?
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");
}
}
}
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)
{
}
}
}
Copy link to clipboard
Copied
yes i see HI in output panel but problem is still same (not working)
Copy link to clipboard
Copied
attach a screenshot that shows the files in your flash working directory.
Copy link to clipboard
Copied
you mean this
Copy link to clipboard
Copied
boss any suggestion??
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
Copy link to clipboard
Copied
can u give me this file in FLASH CS5.5
Copy link to clipboard
Copied
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
Is this problem come for SDK?
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;
}
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;
}
}
}
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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