Posted By

chrisaiv on 10/18/08


Tagged

pdf AIR as3


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

THEPWN3R
vip4lyf
sidneydekoning
mediapoint
donaldleegraham
tspitzr
carlskov


AIR: Load PDF


 / Published in: ActionScript 3
 

Simple example of how to load PDF's using AS3 and AIR. The HTMLLoader class is only available for AIR.

  1. package src{
  2. import flash.display.LoaderInfo;
  3. import flash.display.Sprite;
  4. import flash.display.Stage;
  5. import flash.display.StageAlign;
  6. import flash.display.StageScaleMode;
  7. import flash.events.*;
  8. import flash.html.HTMLLoader;
  9. import flash.html.HTMLPDFCapability;
  10. import flash.net.URLRequest;
  11.  
  12. public class PDFLoader extends Sprite
  13. {
  14. private var appStage:Stage;
  15. private var pdfLoader:HTMLLoader;
  16. private var assetResolverURL:String = "book.pdf";
  17.  
  18. public function PDFLoader()
  19. {
  20. appStage = stage;
  21. appStage.scaleMode = StageScaleMode.NO_SCALE;
  22. appStage.align = StageAlign.TOP_LEFT;
  23.  
  24. if (HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK){
  25. pdfLoader = new HTMLLoader();
  26. pdfLoader.x = appStage.x;
  27. pdfLoader.y = appStage.y;
  28. pdfLoader.width = appStage.width;
  29. pdfLoader.height = appStage.height;
  30. pdfLoader.addEventListener( Event.COMPLETE, onPDFComplete );
  31. pdfLoader.addEventListener(ProgressEvent.PROGRESS, onPDFProgress, false, 0, true);
  32. pdfLoader.load( new URLRequest( assetResolverURL ) );
  33. addChild( pdfLoader );
  34. }
  35.  
  36. }
  37.  
  38. private function getFlashVars():Object
  39. {
  40. return Object( LoaderInfo( this.loaderInfo ).parameters );
  41. }
  42.  
  43. private function onPDFProgress( e:Event ):void
  44. {
  45. }
  46.  
  47. private function onPDFComplete( e:Event ):void
  48. {
  49.  
  50. }
  51.  
  52. }
  53. }

Report this snippet  

You need to login to post a comment.