Learning to use Koolmoves with SWF Studio

I recently was asked to make a video Kiosk for a international Equipment manufacturer, Koolmoves makes it so easy to build the player I took the job even though it was a rush job. You see the company that called is one I usually do film and video work with and had actually recently completed a shoot for this same manufacturer.

They had planned to use DVD for their trade show, but they wanted it to be touch screen with large buttons.

Well After modifying one of the included Skins for the Mediaplayer I completed this pretty quick. It worked well and since it was a once use and controled conditions the limitations of this type of projector file where not a big deal.

Well they must have liked it as I was then ask to create a DVD-ROM to show videos and open PDF and WORD files, open Website and play MP3 files. This one was to be shipped to dealers around the country so the issues with a simple projector were not ok, SO I sought out a solution that would make this all work.

Based on Chris Seahorn's experience with SWF Studio I decided to give it a try.

For starters the trial is FULLY FUNCTIONAL which let me work all they way to client approval of the first demo without having to prepay for the program. The exes that it creates just expire one day after first run.

Well getting the a basic flash program to work in SWF Studio is easy, I did have a couple of issues that mostly turned out to be me not understanding some things.
My first attempt used a Listbox and a Mediaplayer and when I ran them in SWF Studio they were empty...

Well it wasn't until Chris looked at my KM code did he point out that when your swf file is in the exe it doesn't know where to find the video files so you have two choices.

  1. Embed the assest by just dropping them into the files panel of SWF Studio
  2. Use ssGlobals.ssStartDir variable available in SWF Studio ( I totally missed this in my haste)
I made my thumbnails movieclip buttons and added the file names like this
vpanel.mc3.file=ssGlobals.ssStartDir+"/video/2600_Walkaround_Web.mov";
So ssGlobals.ssStartDir resolves to the directory that the EXE is running from and I have the videos in a subfolder /video/.

and then I create the playlist in my onclick handler
function playVideo(e:MouseEvent):void{
trace("cicked");
trace(e.currentTarget);
var pl:String=new String;
 pl='<playlist pause="false"><item label=""><video src="'+e.currentTarget.src+'"/></item></playlist>';
 trace(pl);
 mp1.setXMLPlaylist(pl);
}
And Voila it worked.

So this got me going (I won't bore you with all the drama of how we ended up changing everything and hiring an art director for the graphics and the pain of sorting that out)

Now my next big issue was loading the pdf files.
If the end user has Acrobat Reader it was pretty straight forward, and this is what I did initially.
I just made a button for each PDF and used the SWF Studio command ssShell.Invoke and it worked great. So I sent a demo to the client and they couldn't open the pdf's, Turns out that if you have the Full Acrobat program it doesn't like being called from another program. So how to get around this.
Once again SWF Studio had all the tools I needed, It required a good deal of help from the Northcode folks to get me past my misunderstanding but the tools are there.

Here's what I did:

I got a copy of a program called SumatraPDF that is a free pdf viewer that can be distributed unlike better known readers like Foxit.

So I put SumatraPDF in a folder called /other/ and then I to determine if the user has Reader, Fortuantly I have one computer with Acrobat and one with just reader.
So SWF Studio has a method call ssCore.Shell.getDefaultApplication that will report what application is
installed to handle an extension. So I check for what the system will use to open PDF files.

I coded this

 var userReader:Boolean=false;

var hasReader=ssCore.Shell.getDefaultApplication({extension:"pdf"});

   if (hasReader.success)
   {
      trace(hasReader.result);
      trace(hasReader.result.search("AcroRd32.exe"));
      if (hasReader.result.search("AcroRd32.exe")<0)
      {
         trace("not AcroRd32.exe");
         useReader=false;
      }else{
         trace ("has AcroRd32.exe");
         useReader=true;
      }
   }else{
         useReader=false;
   }


This worked great So I can now use ssShell.invoke if useReader is true and SumatraPDF is false. Or so I thought.

Turns out that SumatraPDF didn't understand the long file names so for c://my documents/disk/pdf/Intro Letter.pdf it tried to open c://my and documents/disk/pdf/Intro and letter.pdf and needless to say this was not good. Well fortunately there is another command called getShortPath that will convert the long path to the old dos type file path.

I did stuggle a little with this as It wasn't clear to me that while flash allows forward slashes for paths Windows really uses backslashes and the getShortPath pass the path directly to the OS and required backslashes.

The resultant code was:
function openPDF(e:MouseEvent):void{

    filename=e.currentTarget.label.text;
    trace (filename);
    if (useReader){
    trace("using Reader");
        ssCore.Shell.invoke({path:"startDir://pdf/"+filename});
   }else{
           trace("using Sumatra");
           var shortpath=ssCore.Shell.getShortPath({path:ssGlobals.ssStartDir+"\\pdf\\"+filename});
           trace ("success "+shortpath.success);
           trace ("error "+shortpath.Error.Description);
           trace ("result "+shortpath.result);
           ssCore.Shell.execute({path:"startDir://other//SumatraPDF.exe",arguments:shortpath.result});
   }
   
}


Success! With TweenMax for sliding panels in and out. it all worked great. Thanks Northcode.
In the end the client was happy, I just wish I'd had more time to plan this whole thing from the start, I would have been able to give them more, like they wanted to allow setting the wallpaper and I wanted to offer a screensaver (which SWF Studio makes easily).

Postscript:
I never did get the listbox to worked when added via the GUI but scripted works just fine, so this is a minor issue.

Reblog this post [with Zemanta]

2 comments:

André said...

hmm, you might have saved yourself a lot of trouble if you would have read / known about the pathing issues before ;) It´s a very common mistake for first time swf studio users...
read up on it here http://www.northcode.com/forums/showthread.php?t=9892&highlight=file+path

I guess Ill write a post in the getting started section about it...

Bret said...

True Might have, of course as is probably often the case the project dropped in my lap at the last moment and I was rushing it done in a couple of days and sadly I didn't know what I didn't know. And believe me when I say that this issue only highlighted the great support Northcode offers on their forum.

Post a Comment

Search

Loading...

About Me