PDA

View Full Version : How do I publish bitmaps with unique .swf names


Nowhaus
03-02-2007, 07:50 PM
I am new to JSFL.
I am taking a bunch of bitmaps in the Library and having flash place the image on the stage, then publish the .SWF as a unique name. I don't see how to change the .SWF name as a different file name.

So far it seems I need to save the file as a new .FLA then publish. But this will make new .FLA files that I do not need.

mylibrary = fl.getDocumentDOM().library;

//get items in library in an Array
itemArray = mylibrary.items;
totalCount = itemArray.length;
var picWidth = fl.getDocumentDOM().width;
var picHeight = fl.getDocumentDOM().height;
var picX = picWidth/2;
var picY = picHeight/2;

for(var i = 0; i < totalCount; i++)
{
myItem = itemArray[i];
myItemType = itemArray[i].itemType;
myItemName = itemArray[i].name;
myItemNoExt = stripExt(itemArray[i].name);
myItemWidth = itemArray[i].width;
if(myItemType == 'bitmap')
{
mylibrary.addItemToDocument({x:picX, y:picY}, myItemName);
fl.outputPanel.trace("new Name"+myItemNoExt);
compile(myItemNoExt);
}
}

function stripExt(picName)
{
var indexNo = picName.indexOf('.');
var newName = picName.slice(0, indexNo);
return newName;
}

function compile(stripName)
{
// stripName is the unique name
var doc = fl.getDocumentDOM();
var swfName = stripName + '.swf';
fl.outputPanel.clear();
doc.publish(swfName); // How do I change the name?

}