This content has been marked as final. Show 4 replies
If I understand correctly, your query returns a string representing the
path to an image, and you now need to display this image in Director. If
so, you can set the filename of an existing - or newly created - #bitmap
to this path. For example:
-- tPath returned from query
-- uses Buddy API, but any xtra with a 'file exists' method would do:
if baFileExists( tPath ) then
member("linked bitmap").filename = tPath
You will need to make image import xtras available to your projector to
support image types like tiff, png, etc. as well as the Mix Services xtra
There /are/ xtras available which support databases that can store
images natively as opposed to strings pointing to external files. You
need to consider the implications of image files being unavailable when
Thanks for this. I am now wondering whether it would be better/possible to have all the images as cast members in the movie since none of the images will ever change. Because the Director file generates 10 random questions each with 4 possible images there would be 40 bmp images stored in the cast. If I were to store the cast member names i.e. img1, img2 - img40 in the database, would it be possible to use these strings in order to display the 4 relevant images.
For example if I had 4 empty bmp cast members named image1, image2, image3, image4 is it possible to use the 4 text strings returned from the database in order to display the relevant images in these 4 cast members?
Hope this makes sense.
As I understand it, you're considering two approaches: all your images as external files, with the filenames in your database, or all your images as castmembers, with the cast member names in your database.
Both approaches should be fairly simple to implement.
For the first approach, you'll need 4 empty bitmap cast members (named image1, image2, image3, image4)
Your query will return the filenames of 4 external image files, so you need to set the filenames of your empty bitmap cast members to the filenames retrieved as Sean described above. eg:
member("image1").filename = queryResultFilename1
member("image2").filename = queryResultFilename2
member("image3").filename = queryResultFilename3
member("image4").filename = queryResultFilename4
You then just need to make sure that you have placed those bitmap cast members on stage as sprites, and they will display the correct images.
In your alternative approach, where you have all the images present in the cast, you will need to have one empty bitmap cast member, as a 'placeholder'. Then place 4 copies of this bitmap on stage, which creates 4 sprites.
Your program will then need to set the cast member of each sprite to the relevant image, based on the cast member names returned by your query from the database. For example, if your 4 placeholder sprites happen to be in channels 11-14, your code might look like this:
hope this helps,
Thanks for the help. I have decided to use the approach using all images as cast members. I have been playing around with the code and found that the following also works.
member("image1").image = member(tPath).image
member("image2").image = member(tPath).image
member("image3").image = member(tPath).image
member("image4").image = member(tPath).image