This content has been marked as final. Show 5 replies
> 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
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)
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.
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":
if baFileExists("c:\photo\1\photo.jpg") then
Make sure that this script is saved as a #movie script. And make sure
you have buddyAPI installed.
Thanks Mike Blaustein, that worked great! Is there a way to constrain the imported photo to the correct proportions?
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).