Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Parse CSV File
Valentina
ESCAPE Video Studio
Irregular MIAW
Whitemedia: Tool Xtras and behaviors for Director.
SpellCatcher
Show Me Movies
Yak
DiskJockey CD-ROM Builder
IMidi Xtra
 

 

 

Article Pulling in Those Graphics

Added on 7/26/1999

 

Compatibilities:
D7 D8 Mac PC

This item has not yet been rated

Author: MediaMacros (website)

I have been working on a very large project that gets updated rather regularly. Because of that we have been using linked graphics, so we can quickly update without having to swap out cast members. Now that we are done I face the task of importing all 3000+ graphics into internal graphics so the screens won't be accessible. Is there a better way I can do this?

First of all, DON'T DO THIS BY HAND!  Sorry to "yell" but you can cost yourself hours of time, possible mistakes, and a lot of headaches doing this.   A lot of developers use lingo to write fancy code for the end user, but then overlook its possibilities to speed up their own projects.  Without ever starting the playback head, you can do some great things with some very simple scripts.  Lets look at what you want to do...

First we examine the problem. You have images that Director needs and is currently using, but you want to remove the bitmap data from outside the projector and bring it in.  Once a project is opened Director reads all of this data and behaves almost exactly the same whether the graphics are linked or are part of the cast itself.   One of the overlooked properties of each cast member is the "media" property.  Think of this as a video tape.  The tape itself tells us what type of video you are using, the name is the sticker on the front.  You can test the height, width, color, etc., but everything in that box is part of the media.  Now all we need to do is step through all of our casts and get each bitmap members name and media, then replace the existing member with the new one.  The beauty of the score is that it only holds a reference to a cast member, so we can swap these without the fear of loosing a link to a cast member.  Here is the basic code...

on importLinkedBitmaps
  set castNumbers = the number of castlibs
  repeat with y = 1 to the number of castlibs
    set howMany = the number of members of castlib y
    repeat with x = 1 to howMany
      set theMember = member x of castlib y
      if the type of theMember = #bitmap then
        if the fileName of theMember <> "" then
          set theMedia = the media of theMember
          set theName = the name of theMember
          erase member theMember
          set theMember = new(#bitmap, member x of castlib y)
          set the media of theMember = theMedia
          set the name of theMember = theName
        end if
      end if
    end repeat
  end repeat
end

First we start a repeat loop that goes through each cast library.   From there we go through each cast member and check it to see if it is a bitmap member.  If so we check to see if it is linked by looking to see if it has a "filename".  If so we copy the member's location in the cast (theMember variable), the member's name and the member's media.  Then we delete the original using the "erase member" command and create a new one in the same location, then drop all the info back in.  Running this script one time will pull all of those graphics in for you and save a lot of time.  Just run the command, go get a cup of coffee, and by the time you return, they will all be done.  (Then surf the net for a while or play some games at shockwave.com.  After all, your boss thinks this is going to take hours, right?)  

If you want to make the code a little fancier, you can allow for other cast member types (audio, etc.), restrict it to certain casts, or whatever ideas your imagination can dream up.  Happy coding!

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail