PDA

View Full Version : Script to import and replace images from the library


tioan
09-19-2008, 04:46 PM
Hi all,
i'm on a project in which i have a bounch of images (about 35) in a flash file that they are manipulated in various ways. I have to make a different file for about 100 groups of pictures. All the files are in the same dimensions so i just import the new images each time by right clicking on the image on the library and pressing import, then save as.. etc
I'm looking for a way to bypass this uncomfortable situation by creating a jsfl command that does the following:
For conveniance lets say that i have numberd the images in the library and in my folders with a proper name (ie img1.jpg etc)

for (i=0; i<number of images; i++){
var item = "img"+i+".jpg"
import new file named "somethink"+i+.jpg from a specified folder and replace the existing one
}

I am not very familiar with JSFL and i don't even know if this can be done, i hope you can help me.

* yes i know it should be done using XML or somethink else to load the images externally, at the first place, but some genius decided that it should be done this way

tioan
09-19-2008, 09:33 PM
trying a workaround for this i thought that i could move the new pictures in the folder from which i imported the originals and then try to update them, using this script:

function init()
{
fl.outputPanel.clear();
var item_array = fl.getDocumentDOM().library.items;
var i = item_array.length;
while(i–)
{
var item = item_array[i];
if(item.itemType == “bitmap”)
{
var resp = fl.getDocumentDOM().library.updateItem(item.name)
fl.trace(”Updating get: ” + resp + ” on item: ” + item.name);
}
}
fl.trace(”———————————————-”);
fl.trace(”Updated ” + item_array.length + ” images.”);
fl.trace(”———————————————-”);

}

init();


But as i realized updateItem is causing flash to crash.:mad: