29 Replies Latest reply on Feb 4, 2008 5:37 PM by Newsgroup_User

    Opening an external image.

    Jacoolh
      I currently have a small thumbnail image which I need to open up the larger version of it on a click. Like most movie websites do. (It's a wallpaper thing).
        • 1. Re: Opening an external image.
          robdillon Most Valuable Participant
          What have you tried so far?
          • 2. Re: Opening an external image.
            Jacoolh Level 1
            Nothing, I'm a complete n00b with Director and want the image to open an external bigger jpeg of it.
            • 3. Re: Opening an external image.
              Level 7
              If by external, you mean that you want the full size image to open
              outside of Director, as in it will open in whatever applpication the
              user has associated with that file type, you can use the BuddyAPI xtra
              (it is free to use up to 2 functions, so for this one function, it would
              be free)

              on mouseUp me
              baOpenFile(the moviePath&"BigVersion.jpg","normal")
              end
              • 4. Re: Opening an external image.
                Jacoolh Level 1
                What is BuddyAPI Xtra? A plugin or something?
                As I said, complete n00b. I used director for the first time about 2 weeks ago.
                • 5. Re: Opening an external image.
                  Level 7
                  Yes it is a plugin. You can download it from

                  http://www.mods.com.au/budapi

                  Once you install it (according to the instructions it comes with), you
                  can use the code I included in my last message to open the large image.
                  • 6. Re: Opening an external image.
                    Level 7
                    An Xtra is a library of functions that extend Directors capabilities.
                    Some were made by Macromedia and others were made by independent
                    developers. In this case the BuddyAPI is a well known xtra that allows
                    Director programs to call functions native to the Operating System.

                    You do not need any xtras in order to import an external image into
                    Director. Every bitmap cast member has a property called 'fileName'. If
                    the bitmap cast member is stored internally to your program, then its
                    fileName property is null. If the bitmap is stored externally then its
                    fileName property is the full path to the file.

                    Your code can read or change the fileName property as needed. There are
                    lots of ways to accomplish what you want to do. One of them would be to
                    have a 'placeHolder' bitmap cast member in your cast. When someone
                    clicks the thumbnail, your code can change the fileName property to the
                    appropriate fileName. Thus your placeholder will now have the desired
                    image. Click another thumbnail, change the fileName property and it
                    changes again.
                    • 7. Re: Opening an external image.
                      Jacoolh Level 1
                      Is there a way to do this without plugins? As I have to use director at college, where the plugin will not be installed and I am unable to change that.
                      • 8. Re: Opening an external image.
                        Level 7
                        You can do it the way Dave said which will display the image inside of
                        the Director window.
                        • 9. Re: Opening an external image.
                          Jacoolh Level 1
                          What is the exact code I would need? Please forgive me for sounding like such a *******.
                          • 10. Re: Opening an external image.
                            Jacoolh Level 1
                            Just that Dave C's post was a little confusing
                            • 11. Re: Opening an external image.
                              Level 7
                              Hi Jacoolh. I would be glad to provide more detail, even some code.
                              Would you mind answering a few questions first?

                              1) Are you sure you need to store the large images externally? There are
                              some good reasons to do so (you have lots of images, you want to change
                              them out without having to republish your file, etc). But if there is no
                              good reason to do so, then it is less complicated to keep them internal.

                              2) You don't really have to have a separate thumbnail image, assuming it
                              is just a tiny version of the full sized image. Director can make very
                              good 'thumbnails' for you.

                              3) Where do you want the full size image to be displayed? On the stage?
                              In a separate Director window? Opened in a browser or some other
                              application?

                              These are just a few of the decisions you have to make before you can
                              write code. I made a game with Director that does something just like
                              this. When the program starts, it reads in external graphics files from
                              a particular directory. The program then creates thumbnail images and
                              displays them in a separate Director window. Clicking on the thumbnail
                              opens the full image in another Director window. If you want to see it,
                              go to http://v-fort.org/ and click the screenshots link on the right.
                              You can download the game itself if you want to see it in action.
                              • 12. Re: Opening an external image.
                                Jacoolh Level 1
                                I do have them imported and I think it would be easier to have it open the default browser for the user's system.
                                • 13. Re: Opening an external image.
                                  Level 7
                                  Jacoolh wrote:
                                  > I do have them imported and I think it would be easier to have it open the default browser for the user's system.

                                  If you want to open the full size image in the users default browser,
                                  then the easiest way is to keep the full sized image as an external
                                  file. In your director file you will have a thumbnail sized image, correct?

                                  Director has a function named "open" which you can look up in the help.
                                  It opens a file with a specified application. For example, lets say you
                                  want to open a file called "picture.jpg" with th users default browser.

                                  Director doesn't have the built in ability to know what the users
                                  default browser is. That is where an xtra like Buddy API comes in handy.
                                  So the first thing you need to do is go to their website
                                  http://www.mods.com.au and download, then install the Buddy API xtra.
                                  They let you use 2 functions for free. You only need one at this point.

                                  Once you have the Buddy API xtra installed the rest is pretty easy. Use
                                  Directors Open function along with the function from Buddy API which
                                  returns the users default browser. It is a simple as attaching this code
                                  to you "thumbnail" sprite.

                                  --start of code

                                  on mouseUp me
                                  open the moviePath & "picture.jpg" with baFindApp("htm")
                                  end

                                  --end of code

                                  This does assume that the picture.jpg file is in the same folder as your
                                  Director file. Try it and let us know how it works out.



                                  • 14. Re: Opening an external image.
                                    Level 7
                                    Of course if you are going to use BuddyAPI to begin with, you may as
                                    well use this command to open your image instead:

                                    baOpenFile(the moviePath&"picture.jpg","normal")

                                    That will open the image in whatever program the user has associated
                                    with jpgs. So, instead of defaulting to a browser, it will open in the
                                    program that the user is familiar with when opening jpg images.

                                    Unless there is a reason that you want the image to open in a browser...
                                    in which case Dave's code is best.
                                    • 15. Re: Opening an external image.
                                      Jacoolh Level 1
                                      I'll try it, but does the movie and the image have to be in the same folder?
                                      • 16. Re: Opening an external image.
                                        Jacoolh Level 1
                                        I'll try it, but does the movie and the image have to be in the same folder?
                                        • 17. Re: Opening an external image.
                                          Level 7
                                          Jacoolh wrote:
                                          > I'll try it, but does the movie and the image have to be in the same folder?

                                          Not if you change the path to the file. Where the code I supplied used

                                          the moviePath & "picture.jpg"

                                          you could certainly substitute another path.
                                          • 18. Re: Opening an external image.
                                            Jacoolh Level 1
                                            Does the Buddy API Xtra go into Macromedia\Director MX 2004\Configuration\Xtras\
                                            • 19. Re: Opening an external image.
                                              Jacoolh Level 1
                                              It seems nothing is happening when the movie is played.

                                              baOpenFile (the moviePath&"Wallpaper1.jpg","normal")
                                              • 20. Re: Opening an external image.
                                                Level 7

                                                > Does the Buddy API Xtra go into Macromedia\Director MX 2004\Configuration\Xtras\

                                                Yes. That is exactly where it goes
                                                • 21. Re: Opening an external image.
                                                  Level 7
                                                  Jacoolh wrote:
                                                  > It seems nothing is happening when the movie is played.
                                                  >
                                                  > baOpenFile (the moviePath&"Wallpaper1.jpg","normal")

                                                  baOpenFile will give you an error code when it is run. Change the
                                                  command to this:


                                                  put baOpenFile (the moviePath&"Wallpaper1.jpg","normal")

                                                  I just inserted the word 'put' in front of it. That will put a number
                                                  into your message window when the command runs. Compare that number to
                                                  the list in the help file and it should tell you what the problem is.
                                                  • 22. Re: Opening an external image.
                                                    Jacoolh Level 1
                                                    put baOpenFile (the moviePath&"Wallpaper1.jpg","normal")

                                                    This is not giving an error code though. Nothing is happening at all, even when the button is clicked.
                                                    • 23. Re: Opening an external image.
                                                      Level 7
                                                      In that case, the code is not running. Perhaps you have not put the
                                                      script on the button? Try putting that code in the message window.
                                                      Does it work there?
                                                      • 24. Re: Opening an external image.
                                                        Jacoolh Level 1
                                                        on mouseUp me
                                                        put baOpenFile (the moviePath&"Wallpaper1.jpg","normal")
                                                        end

                                                        This is what's on the image, but nothing is happening.
                                                        • 25. Re: Opening an external image.
                                                          Level 7
                                                          I will reiterate my previous message:

                                                          In that case, the code is not running. Perhaps you have not put the
                                                          script on the button? Try putting that code in the message window. Does
                                                          it work there?

                                                          For emphasis sake, I will repeat the important passage:

                                                          Try putting that code in the message window. Does it work there?
                                                          • 26. Re: Opening an external image.
                                                            Level 7
                                                            Mike Blaustein wrote:
                                                            > I will reiterate my previous message:
                                                            >
                                                            > In that case, the code is not running. Perhaps you have not put the
                                                            > script on the button? Try putting that code in the message window.
                                                            > Does it work there?
                                                            >
                                                            > For emphasis sake, I will repeat the important passage:
                                                            >
                                                            > Try putting that code in the message window. Does it work there?

                                                            Note that "the moviePath" may not exist until the Director movie has been
                                                            saved.

                                                            Andrew


                                                            • 27. Opening an external image.
                                                              Jacoolh Level 1
                                                              I don't think I'll be able to use this code as the movie will be sent off for moderation (It's coursework) on a PC that won't have the Xtra on it. Is there absolutely no way this can be done without an Xtra?
                                                              • 28. Re: Opening an external image.
                                                                Level 7
                                                                Jacoolh wrote:
                                                                > I don't think I'll be able to use this code as the movie will be sent off for moderation on a PC that won't have the Xtra on it. Is there absolutely no way this can be done without an Xtra?

                                                                You can use Directors built in 'Open' function (no Xtra required). The
                                                                problem is that you have to know the exact path to the executable file
                                                                to open the document. Something like this

                                                                open the moviePath & "myPic.jpg" with "C:\Program Files\Internet
                                                                Explorer\IEXPLORE.EXE"
                                                                • 29. Re: Opening an external image.
                                                                  Level 7
                                                                  Dave C <no@no.com> posted in macromedia.director.lingo:

                                                                  > Jacoolh wrote:
                                                                  >> I don't think I'll be able to use this code as the movie will be sent
                                                                  >> off for moderation on a PC that won't have the Xtra on it. Is there
                                                                  >> absolutely no way this can be done without an Xtra?
                                                                  >
                                                                  > You can use Directors built in 'Open' function (no Xtra required). The
                                                                  > problem is that you have to know the exact path to the executable file
                                                                  > to open the document. Something like this
                                                                  >
                                                                  > open the moviePath & "myPic.jpg" with "C:\Program Files\Internet
                                                                  > Explorer\IEXPLORE.EXE"

                                                                  And you might be able to get the path to the browser with browserName().

                                                                  open the moviePath & "myPic.jpg" with browserName()

                                                                  However, Lingo's open command often has problems with paths containing
                                                                  spaces.

                                                                  It /sometimes/ helps to enclose the paths in quotes.

                                                                  open QUOTE &the moviePath & "myPic.jpg" &QUOTE with QUOTE &browserName()
                                                                  &QUOTE

                                                                  I haven't tested it, but it may require one or more of Director's net Xtras.



                                                                  --
                                                                  Mark A. Boyd
                                                                  Keep-On-Learnin' :)