A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: PDF.. XML... confusion reins!!!

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    14

    Question PDF.. XML... confusion reins!!!

    Hi Everyone,

    Hoping someone can help. I'm basically creating a Brochure CD, which contains a range of brochures.

    The CD contains a lead swf which loads up, and is the navigation for 3 other SWF's (one for each product area). These swf's have an itunes coverflow banner which loads content from an xml (the content is a Thumbnail, and 2 links, one to a website and one to a PDF)

    When the link goes to a Website.. works perfectly. Trouble is when I try to get it to open the PDF. I can get it to open in a browser, but as it's going on a CD I assume I can't do it that way.

    As it's going to be on a CD, I assume I'll need to use fscommand, but as it's calling from an XML file, and not direct from a button.. I'm confused.

    Can anyone explain how I could do this?

    I also have SWF Studio as a trial.. but I haven't a clue how to work it.

    If anyone can help, I'd be eternally grateful.

    Sarah

  2. #2
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    You can use getURL to open the PDF file if you like, even if the projector is going to run from a CD. The PDF file will open in a browser IF the user has the Acrobat Reader plugin installed for their browser.

    I have a few clues about how SWF Studio works if you want to give that a shot.

    With SWF Studio, or if you just want to use something other than getURL to open the PDF, what you have to do is find the code behind the button (easy if you wrote it, less fun if someone else wrote it) that reads the PDF file name from the XML and modify that code to do what you want.

  3. #3
    Junior Member
    Join Date
    Apr 2009
    Posts
    14
    Quote Originally Posted by Northcode View Post
    You can use getURL to open the PDF file if you like, even if the projector is going to run from a CD. The PDF file will open in a browser IF the user has the Acrobat Reader plugin installed for their browser.

    I have a few clues about how SWF Studio works if you want to give that a shot.

    With SWF Studio, or if you just want to use something other than getURL to open the PDF, what you have to do is find the code behind the button (easy if you wrote it, less fun if someone else wrote it) that reads the PDF file name from the XML and modify that code to do what you want.
    Thanks for replying so fast! I'd like to go the SWF Studio route to be honest - looks better to have the PDF open in Reader than the browser.

    I think I may know the code that calls the link:

    img_info.albumLink.enabled = true;
    if (infostruc[current - 1].albumLink == undefined) {
    img_info.albumLink.enabled = false;
    } else {
    if (infostruc[current - 1].albumLink == "undefined") {
    img_info.albumLink.enabled = false;
    } else {
    img_info.albumLink.onPress = function() {
    getURL(infostruc[current - 1].albumLink, "_blank");

    I've uploaded the FLA of one of the Product Areas, Frame 2, Line 326.

    I've also uploaded a text file of the XML, so you can see the code.

    Thanks
    Attached Files Attached Files

  4. #4
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    I would replace the line you've highlighted with a function call like openDocument(infostruc[current - 1].albumLink); and include the openDocument function (below) to do the work for you.

    The openDocument function will figure out whether you're trying to open a PDF file or something else and do the right thing. It should be vert easy to extend this function to handle other document types if you need that in the future too.

    Code:
    function openDocument(link:String)
    {
       var i:Number = link.lastIndexOf(".");
       var ext:String = link.substr(i+1, link.length-i-1).toLowerCase();
    	
       if (ext == "pdf")
          ssCore.Shell.open({path:ssGlobals.ssStartDir + "\\" + link});
       else
          getURL(path, "_blank");
    }

  5. #5
    Junior Member
    Join Date
    Apr 2009
    Posts
    14
    Thanks - would the quoted code go directly below the highlighted line?

    Also, do I need to do anything to the XML file?

  6. #6
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    The function can go right at the beginning of the code on that frame, just after all your imports and variable declarations (global scope). That way you can call it from anywhere in that pile of code.

    In the openDocument function I added the path to the EXE file (ssGlobals.ssStartDir) to the link from the XML file to make an absolute path from the relative path in the XML file so the XML file shouldn't require any changes.

  7. #7
    Junior Member
    Join Date
    Apr 2009
    Posts
    14
    Great thanks - right, now I suppose the actual SWF Studio packaging.

    Am I correct in thinking all I need to do is (To test this SWF anyway) publish the SWF via SWF Studio, adding in border options icons etc.. Press Build and let it do it's magic. I don't need to do anything else to get it to load?

    I should say Im on Vista... and a bit of a newbie when it comes to Flash. Lol.

  8. #8
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    That should do it. Remember that your XML file (and whatever other files your SWF was using) need to be in the same position relative to the EXE as they were to the original SWF.

  9. #9
    Junior Member
    Join Date
    Apr 2009
    Posts
    14
    Hmm.. problem. Work have decided that we cant go down the SWF studio route: costs etc blah blah blah. So, I thought going down the Batch/Proxy route may work.

    Could you possible explain how I would go about it? I want to avoid the black dos box if possible, but when I've follwed the general instructions, Vista opens the batch file in Firefox... as a text file.

  10. #10
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    You'll need to change the openDocument function slightly and adjust the way the proxy normally works so you don't have to change your XML files. What we'll do is use fscommand EXEC instead of ssCore.Shell.open and modify the link so it will work with the fscommand.

    Code:
    function openDocument(link:String)
    {
       var i:Number = link.lastIndexOf(".");
       var ext:String = link.substr(i+1, link.length-i-1).toLowerCase();
       link = link.split("\\").join("_");
    	
       if (ext == "pdf")
       {
          link = link.split(".pdf").join(".exe");
          fscommand("exec",  link);
       }
       else
       {
          getURL(path, "_blank");
       }
    }
    What I did was replace the \ in the path with an _ (since you can't have a path in the EXEC command). So what you have to do is create one EXE and one BAT file for every PDF file you may want to open. All of these files need to be in the fscommand folder.

    If the link in the XML was Files\Style300Eng.pdf you would create a BAT file called Files_Style300Eng.bat and create a copy of the proxy utility called Files_Style300Eng.exe and put them both in the fscommand folder. Next you would have to put the command to open the PDF file in the BAT file, something like start Files\_Style300Eng.pdf.

    It's a LOT more work to do it this way. Not on the code side, but to prep all the BAT and EXE files you'll need. If you can automate it by processing your XML files that would definitely be the way to go.
    Last edited by Northcode; 04-24-2009 at 02:41 PM.

  11. #11
    Junior Member
    Join Date
    Apr 2009
    Posts
    14
    Hi Northcode,

    Well, I got the batch files and the Proxy files working perfectly. Trouble is (as always with me!) it wont open in the flash exe. I inserted the code above as you said, but still having problems. Can you take a look for me and see if I've made a glaringly obvious mistake,

    All files (except images) are in the Zip. The proxy, batch file should go in an fscommand folder (thats how they are on my machine)

    <ADMIN: Download removed. Was flagged as bad file by search engines>
    Last edited by brad jones; 10-09-2015 at 03:30 PM. Reason: removed attachment

  12. #12
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    When I add trace statements to the code, the albumLink and artistLink onPress functions are never called. They are enabled, just not called when you click on the image. I can see the updateInfo function being called at the right times (on click and double click) but I don't know what else is missing. If the openDocument function is called it will work. I may be missing something that's stopping it from working but your next job it to make sure the openDocument function is actually being called.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center