5 Replies Latest reply on Apr 1, 2009 9:06 AM by Chunick

    User change photo

    jfifel
      I want to make a director movie where the user can put a photo in a certain place on his computer and the movie will use it in place of the original photo in the movie. Is this possible?
        • 1. Re: User change photo
          Level 7
          > I want to make a director movie where the user can put a photo in a certain place on his computer and the movie will use it in place of the original photo in the movie. Is this possible?

          Yes it is.

          Break it into steps:
          1). Check for a (named - is the name important?) image in a particular
          folder
          2). If it's there, import it over the top of the current image

          The Buddy API xtra can help with determining whether a file exists
          (baFileExists), or generating a list of file types in a folder
          (baFileList), or even presenting a file-select dialog (baGetFilename)
          http://www.mods.com.au
          • 2. Re: User change photo
            jfifel Level 1
            I want the user to put a photo in a certain place (say C:/photo/1) and have the director movie automatically replace the existing photo with the one in the users directory.
            • 3. Re: User change photo
              Level 7
              Assuming that you know what the name of the photo file is, you can
              simply check for it and bring it it. If you do not know the name of the
              file, then it will be more complex... In this example, the filename will
              be "photo.jpg" and the member inside Director that you are replacing
              will be named "photoMember":


              on startMovie
              if baFileExists("c:\photo\1\photo.jpg") then
              member("photoMember").filename="c:\photo\1\photo.jpg"
              end if
              end

              Make sure that this script is saved as a #movie script. And make sure
              you have buddyAPI installed.
              • 4. Re: User change photo
                jfifel Level 1
                Thanks Mike Blaustein, that worked great! Is there a way to constrain the imported photo to the correct proportions?
                • 5. Re: User change photo
                  Chunick Level 3
                  you can set the stretch property of the sprite that the image is in... however, that also means changing your code:

                  -- create a new member
                  mem = new(#bitmap)
                  -- set the filename of the member to the external image path
                  mem.filename = "c:\photo\1\photo.jpg"
                  -- set the stretch property of the placeholder sprite image
                  -- on the stage to true
                  sprite(x).stretch = true
                  -- set the member of the sprite
                  sprite(x).member = mem

                  This will get the results you are looking for... note, however, that the image proportions will be that of the sprite... and also note that sprite(x) refers the the sprite number or name (if using MX2004 or higher, in which sprites can now have names).