Posted by SWFNewbie in SWF Studio V3 on May 26 2008, 08:25 am

Hello,

in my Projekt (Flash MX - SWF Studio 3.5) I want to load a pdf file.
The pdf File and the Adobe Reader is on the CD.
During the load of the file I want to show a message for example "Data loading".

I load the File with

ssCore.Shell.execute({path: "startdir://Acrobat 7.0/Reader/AcroRd32.exe",
arguments: "startdir://files/info.pdf"});

that works fine.

But I have not enough experience to the programm the right code for the test if the Reader is open or not.

This is what I have, but it doesen't work.

function isAcrobatRunning(r){
var r:Object;
var pos:int = r.result.indexOf("Adobe Reader");
if(pos >=1){
return 1;
}else{
return 0;
}
}

if (isAcrobatRunning(ssCore.SysInfo.getWindowList({}) == 1)){
gotoAndStop(1);
_root.gotoAndStop(1);
} else {
gotoAndPlay(2);
}

It would be fine if you have any idea what could be wrong.


Posted by mbd in SWF Studio V3 on May 26 2008, 11:21 am

The option you are looking for is in ssCore.Shell.execute. Take a look at the waitForWindow parameter. Set it to true and add a callback to your command so that it will be called when Acrobat is visible.

I noticed that you are trying to execute a command synchronously. You don't need to use that command at all in this case, but if you want to use any other commands synchronously please be aware: if you are using Flash MX then you won't be able to use the commands synchronously unless you enable the option in SWF Studio to upgrade your SWF to version 8. This can sometimes be problematic for some projects since ActionScript in a SWF published for Flash player 6 is not case-sensitve, but upgrading the SWF in this way means it will be. For info on enabling synchronous commands take a look at the FAQ link in my signature. See also: Synchronous Commands and Upgrading to SWF8 Format.

I also noticed that you are using / characters in your paths. While this might work on your system it isn't guaranteed to work on any other system. The / character is not a Windows folder separator. Here is your code, with added callback as well:

ssCore.Shell.execute({path:"startdir://Acrobat 7.0\\Reader\\AcroRd32.exe", arguments:"startdir://files\\info.pdf", waitForWindow:true}, {callback:"acrobatDisplayed", scope:this});

function acrobatDisplayed(return_obj, callback_obj, error_obj)
{
   if (return_obj.success)
   {
      // The Acrobat window should now be visible.
   }
   else
   {
      ssDebug.trace("ERROR: "+error_obj.description);
   }
}


Posted by SWFNewbie in SWF Studio V3 on May 27 2008, 01:17 am

Thanks, I will check it.


Posted by SWFNewbie in SWF Studio V3 on May 27 2008, 01:50 am

Thanks a lot. It works fine.