Faticus
06-02-2009, 09:10 AM
Hi,
I'm new to AIR and am trying to load PDF files into Flash CS3, which I've managed to do, if they are placed in the same folder as the app, but would like to select PDF's from elsewhere (other folders) and need to know how to include the relevant path. Also after the PDF has loaded and the Clip is resized I lose the PDF and just get a black screen!
Many Thanks in Advance!:eek:
Code below
import flash.display.Sprite;
import flash.html.*;
import flash.net.URLRequest;
import flash.filesystem.*;
function findPDF():void
{
var docFilter:FileFilter = new FileFilter("Documents", "*.pdf;*.doc");
var myFile:File = new File();
myFile.browseForOpen("Open", [docFilter]);
myFile.addEventListener(Event.SELECT, fileSelected);
}
function fileSelected(evt:Event)
{
loadPDF(evt.target.name);
}
function loadPDF(pdfTitle:String):void
{
var request:URLRequest = new URLRequest(pdfTitle);
var pdf:HTMLLoader = new HTMLLoader();
//set the dimensions
pdf.height = 640;
pdf.width = 900;
//call the load method
pdf.load(request);
//add the HTMLLoader object to the display list to make it visible
addChild(pdf);
}
findPDF();
I'm new to AIR and am trying to load PDF files into Flash CS3, which I've managed to do, if they are placed in the same folder as the app, but would like to select PDF's from elsewhere (other folders) and need to know how to include the relevant path. Also after the PDF has loaded and the Clip is resized I lose the PDF and just get a black screen!
Many Thanks in Advance!:eek:
Code below
import flash.display.Sprite;
import flash.html.*;
import flash.net.URLRequest;
import flash.filesystem.*;
function findPDF():void
{
var docFilter:FileFilter = new FileFilter("Documents", "*.pdf;*.doc");
var myFile:File = new File();
myFile.browseForOpen("Open", [docFilter]);
myFile.addEventListener(Event.SELECT, fileSelected);
}
function fileSelected(evt:Event)
{
loadPDF(evt.target.name);
}
function loadPDF(pdfTitle:String):void
{
var request:URLRequest = new URLRequest(pdfTitle);
var pdf:HTMLLoader = new HTMLLoader();
//set the dimensions
pdf.height = 640;
pdf.width = 900;
//call the load method
pdf.load(request);
//add the HTMLLoader object to the display list to make it visible
addChild(pdf);
}
findPDF();