1 Reply Latest reply on Oct 23, 2012 9:04 AM by ChrisAugier

    How can I open an attachment from inside a PDF portfolio using flex 4.1?

    ChrisAugier

      I am currently developing a portfolio and have a DataGrid which lists my sorted attachments.

       

      I can right click on an attachment to open it but I require it to happen on the double click event.

       

      My code currently looks like this (taken from an old example):

       

      private function itemDoubleClicked(event:ListEvent):void

                                    {

       

                                              var itemIndex:int = event.rowIndex;

       

                                              var item:AttachmentImpl = AttachmentImpl(sortedCurrentItems.getItemAt(itemIndex));

       

                                              var command:CommandImpl = collectionManager.host.commands(acrobat.collection.CommandType.PREVIEW);

                                              Alert.show("you double clicked " + item.fileName);

                                              collectionManager.host.selection = [item];

                                              command.execute(item); 

                                    }

       

      but i get a null pointer exception because command is null.

       

      Could anyone give me pointers or another solution?

       

      Thanks,

       

      Chris.

       

      Edit:

       

      I would like to extend this question as follows:

       

      when using 'host.commands' (as i believe is correct) I get the error that host is 'write-only' and therefore can access none of its methods.

       

      The example I use is from here: http://pdfdevjunkie.host.adobe.com/05_sorting.shtml

       

      Using this method, the host is overwritten by doing the following:

       

      public function set host(host:INavigatorHost):void

                                    {

                                                   if(host != null) {

                                                             _host = host;

                                                             startEverything();

                                                   } else {

                                                             _host = null;

                                                             //Alert.show("Navigator Ending");

                                                   }

                                    }

       

      When I try to do this I recieve the error that the method is not set for override.