A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: dynamic links

  1. #1
    susan
    Join Date
    Jun 2005
    Location
    San Francisco
    Posts
    30

    dynamic links

    I want to have a link that is generated if a pdf file is in a particular directory. Something like:

    if (file.pdf is present in ../pdf/) then
    generate link in the swf file that will open the pdf in a new window

    else

    generate text that says 'no pdf file present'.

    Is this possible? And can anyone give me any advice on how to go about this?

    thanks!

  2. #2
    Senior Member
    Join Date
    Oct 2004
    Posts
    134
    you will need some server side scripting for this
    (PHP, ASP, JSP whatever). if you're not taken aback by that, check out the filesystem object for ASP or the file_exists method for PHP.

  3. #3
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    You won't be able to do it easily in any type of coding.

  4. #4
    Junior Member
    Join Date
    Nov 2004
    Posts
    29
    you could say:
    Code:
    on (release) {
         getURL("path/file.pdf");
    }
    you can use that script to open the file!
    but not to ID it....

  5. #5
    14 year old W.I.Z!
    Join Date
    Jul 2005
    Location
    USA
    Posts
    227
    nah, That would open up a browser...hmm...try this: (put this into the frame's actions, and have a text field named 'results')
    Code:
    pdf_url = "file.pdf";
    pdf_loadvars = new LoadVars();
    pdf_loadvars.onLoad = function(success){
    if(success){
    _root.results = "You have the .pdf file, great job";
    }
    _root.results = "No .pdf file, sorry!";
    }
    }
    pdf_loadvars.load(pdf_url);
    Excuse my horrible spelling....you can blame my English teacher for that!

  6. #6
    susan
    Join Date
    Jun 2005
    Location
    San Francisco
    Posts
    30
    If I did it this way I think the pdf file would have to actually load before results would show up? It's a big file.

    Quote Originally Posted by cobrasniper555
    nah, That would open up a browser...hmm...try this: (put this into the frame's actions, and have a text field named 'results')
    Code:
    pdf_url = "file.pdf";
    pdf_loadvars = new LoadVars();
    pdf_loadvars.onLoad = function(success){
    if(success){
    _root.results = "You have the .pdf file, great job";
    }
    _root.results = "No .pdf file, sorry!";
    }
    }
    pdf_loadvars.load(pdf_url);

  7. #7
    Senior Member
    Join Date
    Oct 2004
    Posts
    134
    don't worry, just try it. it really works. the function is called onLoad. tiny glitch in cobra's script: he forgot the 'else'. the snippet should read:
    Code:
    pdf_url = "file.pdf";
    pdf_loadvars = new LoadVars();
    pdf_loadvars.onLoad = function(success){
    if(success){
    _root.results = "You have the .pdf file, great job";
    }else{
    _root.results = "No .pdf file, sorry!";
    }
    }
    pdf_loadvars.load(pdf_url);

  8. #8
    susan
    Join Date
    Jun 2005
    Location
    San Francisco
    Posts
    30
    This works when the pdf file has text in it but not when the pdf is just made up of images.

    It also works with a .txt file when there is text on the file but doesn't when the .txt file is a blank file.

    Also, the pdf file has to load before the text will show up (I tested it with download simulation) which will make the site too slow because there are several files that are large.

    It looks like it may have to be done with some server scripting or by passing the file name as a variable instead of checking for its existance.

    Thanks for all your help and if you have any more ideas please let me know.

    thanks.

  9. #9
    14 year old W.I.Z!
    Join Date
    Jul 2005
    Location
    USA
    Posts
    227
    sorry, i wish i could help some more, but im out of ideas, ill think up on it!
    Excuse my horrible spelling....you can blame my English teacher for that!

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