9 Replies Latest reply on Sep 26, 2009 2:16 AM by KeiserSozai

    Opening files in Director

    KeiserSozai Level 1

      Hi, I used director about 10 years ago to do an interactive CD for a company i was working for at the time. I am currently trying to devise a way where a user can open a pdf file or what ever file they choose from a menu on the screen - not just using a Open File dialogue box - but no matter what i do, it just doesnt work. I copied the xtra into the same directory as the movies, i was trying to open movies using this just for experimentation - i thought if anything this would work, it didn't...

       

      I copied and pasted this command straight from the pages of the help file for the Xtra

       

      -  on mouseclick
      -    object.openFile(Probes.dir, 1)
      -  end

       

      It keeps coming up with this error message...

       

      Operator expected

      object.?openfile(nameoffile.dir, 1)

       

      Don't know what's going on... I wish i kept the older interactive cd...

       

      Damn you hindsight!!!

        • 1. Re: Opening files in Director
          Sean_Wilson Adobe Community Professional

          What is the xtra you are using? Often you have to create an instance of it and use this to access the methods of the xtra. Also, one of your arguments looks like it needs to be a string. Finally, 'mouseclick' is not a native event:

          on mouseUp me
            xObject = xtra("xtra_name_here").new()
            returnedValue = xObject.openFile("Probes.dir", 1)
          end
          
          • 2. Re: Opening files in Director
            Sean_Wilson Adobe Community Professional

            I'm going to guess it's FileIO you're using and I think that's the wrong xtra for what you're trying to achieve. As I understand it, you want to open an arbitrary file in its associated application. File IO will read a file's (binary) contents into a Director variable - I don't think this is what you want. You should download a copy of Buddy API - it's free for up to 2 functions. Read the xtra's documentation for 'baOpenFile()'

            • 3. Re: Opening files in Director
              KeiserSozai Level 1

              Sorry I am using FileIO.x32. I copied and pasted the script in your second post...

               

              Changed a file to a pdf, the script is

               

              here...

              on mouseUp me
                xObject = xtra("FileIo.x32").new()
                returnedValue = xObject.openFile("HeartStyle_Y360_flyer.pdf", 1)
              end

               

              It came up with an error message...

               

              Script error: Object expected

               

              xObject = xtra("FileIo.x32). new()

               

              I am wondering if i need to put something in the brackets after new? If so, what is it? And also, does the file need to be imported into the movie cast library? I haven't been able to do that with a pdf...

               

              I'm a complete noob...

               

              Thanks for your help.


              Trav

              • 4. Re: Opening files in Director
                Sean_Wilson Adobe Community Professional

                That would be:

                on mouseUp me
                  xObject = xtra("FileIo").new()
                  returnedValue = xObject.openFile("HeartStyle_Y360_flyer.pdf", 1)
                end

                However, like I said, I don't think FileIO is the xtra you want to be using - it will read the file data into a Director variable. It will not open a file in it's associated application. Read my second post (again).

                • 5. Re: Opening files in Director
                  KeiserSozai Level 1

                  When you say the Buddy API is useful up to 2 functions. Do you mean it will only work twice or in 2 movies indefinately?

                   

                  Trav

                  • 6. Re: Opening files in Director
                    Sean_Wilson Adobe Community Professional
                    When you say the Buddy API is useful up to 2 functions. Do you mean it will only work twice or in 2 movies indefinately?

                    You can use any 2 functions of the hundred or so it implements, in any movie, any number of times - download it and read the docs, it's all explained there.

                    • 7. Re: Opening files in Director
                      KeiserSozai Level 1

                      I'm now using the Buddy API xtra you suggested I have changed the script to this:

                       

                      on mouseUp me
                        xObject = xtra("Buddy API Xtra").new()
                        returnedValue = xObject.openFile("HeartStyle_Y360_flyer.pdf", 1)
                      end

                       

                       

                      to accommodate the change and I am still getting...

                       

                      Script error:Object expected

                       

                      xObject = xtra("Buddy API Xtra").new()

                       

                      I've tried to include file extensions in the script as well, that didnt work...

                       

                      I even tried...

                       

                      on mouseUp me
                        xObject = xtra("Buddy API Xtra").new()
                        baOpenFile( the moviePath & "HeartStyle_Y360_flyer.pdf" , "maximised" )
                      end

                       

                      baOpenfile being a function in Buddy API...

                       

                      This is befuddling... I'm doing something wrong and I am sure it's an easy fix. But I just can't find it.

                      • 8. Re: Opening files in Director
                        Sean_Wilson Adobe Community Professional

                        You don't have to create an instance of Buddy API in order to use its methods - they are "globally" available:

                        on mouseUp me
                          tFile =  the moviePath & "HeartStyle_Y360_flyer.pdf"
                          returnedValue = baOpenFile( tFile, "maximised" )
                          if returnedValue < 32 then
                            alert "Error opening file:" && returnedValue 
                          end if
                        end
                        
                        • 9. Re: Opening files in Director
                          KeiserSozai Level 1

                          Thanks for all your patience and awesome help... the script worked... Now i can get on with finding more questions!

                           

                          Thanks again