6 Replies Latest reply on May 24, 2006 5:39 PM by Newsgroup_User

    Linked images

    Level 7
      I am working on a app that will packaged as an exe. Currently I am including
      20 generic jpg files with the exe, which 20 bitmap cast members are linked
      to. The idea is that the user can replace one or more of the jpgs with their
      own and the program will utilize them.

      Right now, if any of the jpgs are missing when the program starts, it wants
      the user to locate a replacement. I want to avoid this. I want the exe to
      use any jpgs it finds (assuming the follow the proper naming convention),
      but not to complain if some are missing. In other words, I want my program
      to support up to 20 custom jpgs, but not require them.

      Any thoughts on how best to implement this are greatly appreciated.



        • 1. Re: Linked images
          Level 7
          Instead of linking the images, either create bitmap members dynamically, or
          have placeholders and set their fileName property. You can get a list of
          files in a folder using getNthFileNameInFolder, or FileXtra4 or a number of
          others. Then you don't need a naming convention either, unless you use it
          for other reasons, as you can just grab the first 20 jpegs you find in the
          specified folder.

          --
          Dave -
          Adobe Community Expert
          www.blurredistinction.com
          www.macromedia.com/support/forums/team_macromedia/


          • 2. Re: Linked images
            Level 7
            Ah, I see. Very simple. What I was missing (that I now see is clearly
            documented) is that "You can also make unlinked media linked by setting the
            filename of those types of members that support linked media. "

            I also see that if I set its fileName property to zero, I can unlink it. I
            presume that I need to do this somewhere, because the cast member will
            become linked while I am editing the program. Where would be a good place to
            unlink the cast members to ensure that they get saved as unlinked before I
            package?


            • 3. Re: Linked images
              Level 7
              >>Where would be a good place to unlink the cast members to ensure that they
              >>get saved as unlinked before I package?

              on stopMovie should work nicely. You could create the bitmap members on the
              fly and erase them when you're through.


              --
              Dave -
              Adobe Community Expert
              www.blurredistinction.com
              www.macromedia.com/support/forums/team_macromedia/


              • 4. Re: Linked images
                Level 7
                Great help, thanks!


                • 5. Re: Linked images
                  jlem
                  Could a n00b like me get a snippet of sample code to execute such a function - using the "getNth..." method noted above? I have currently 5 images set up to crossfade in a slideshow like format. It would be great to be able to give the clients any number of images to select from depending on whether they've dropped them into an assets folder...

                  Thanks in advance!
                  • 6. Re: Linked images
                    Level 7
                    OK, here is a script that (when the movie starts) dynamically creates a new
                    bitmap cast member for each bitmap image in a folder called AssetFolder. It
                    then makes each member linked to the external bitmap file. It also creates a
                    list called gDynamicBitmapMembers, so that you can reference individual cast
                    members as needed. Beware that some of the lines in the code snippet below
                    may get word wrapped by your news reader.


                    --
                    global gDynamicBitmapMembers

                    on startMovie

                    gDynamicBitmapMembers = []

                    n = 1

                    repeat while getNthFileNameInFolder(the moviePath & "AssetFolder", n) <>
                    EMPTY

                    gDynamicBitmapMembers.add(new(#bitMap))

                    gDynamicBitmapMembers[n].fileName = the moviePath & "AssetFolder\" &
                    getNthFileNameInFolder(the moviePath & "AssetFolder", n)

                    n = n + 1

                    end repeat

                    end