>I'd like to do something similar. I have a single frame in which >I page through a large number of PICTs. I'd like to avoid having >those PICTs in my cast. Instead I'd like to read the files from diskHere are a couple of approaches; the first two assume that you do not need to worry about palettes.
on importPICTFile whichFile set x=the number of cast "thePICT" set the filename of cast "thePICT" to "@:" & whichFile set the name of cast x="thePICT" end
Note 1: you can use THE PATHNAME function instead of "@:" See pgs 52-54 of the "Tips & Tricks" manual that came with Director for more info on pathnames, relative pathnames, and use of the '@' symbol.NOTE 2: If you choose to refer to the castmember containing your PICT by number (i.e., if you won't be moving it around in the cast window) then you do not need the 1st and last lines shown above. The reason they are needed here is that when you import the file the castmember containing the PICT gets renamed by Director to the name of the imported file. Thus the next time you call importFile there will not be a cast called "thePICT" and you will get an error message. :-(
on importPICTFile whichFile
global fileIO,pictFile
if objectP(pictFile) then pictFile(mDispose)
put FileIO(mNew,"read",the pathname &whichFile) into pictFile
if objectP(pictFile) then
set the picture of cast "thePICT" to pictFile(mReadPICT)
else if pictFile=-43 then
-- file not found; see fileIO error codes for more possible error codes
alert "File not found: '" & whichFile
else
...whatever...
end if
pictFile(mDispose)
end
I generally create two lists, one with the filenames of the PICTs available for importing (you can include the pathname as part of each list entry; if you don't store this info in the file list than you will need to modify the importFile handler to include pathname info for your PICT), and another list with their associated palettes (palettes are stored as castmembers). The lists are in the same order (i.e., 3rd palette in paletteArray is associated with the 3rd file in the file list).In this example you pass the appropriate list entry (i.e., which item on the list) to the importFile handler as arrayIndex. Remember, this example assumes you have already set the appropriate palette in some handler before calling importFile. For variety
I use the IMPORTFILEINTO CAST command (it doesn't rename the castmember like the FILENAME OF CAST command).
on importFile arrayIndex global fileList,paletteList set whichFile=getAt(fileList,arrayIndex) importFileInto cast "thePICT", whichFile endor...
The following is untested--I'd be surprised if this worked since I'm not sure that Director will actually update the palette with puppetPalette before the file is imported. You probably need to set the correct palette in one frame then call importFile in the next frame (the problem is making sure that Director actually SETS the new palette BEFORE you import the file and I recall that this did not occur reliably if you did this in the same handler)
on importFile arrayIndex global fileList,paletteList set whichFile=getAt(fileList,arrayIndex) set whichPalette=getAt(paletteList,arrayIndex) puppetPalette whichPalette updateStage importFileInto cast "thePICT", whichFile end-Jeff Markham
UCLA School of Medicine Dept. Molecular and Medical Pharmacology Crump Institute for Biological Imaging 10833 LeConte Ave Los Angeles, CA 90024-6948 jmarkham@mail.nuc.ucla.edu http://www.nuc.ucla.edu