Automated importing/renaming of Flash assets
So I have an AS3 flash project with A LOT of assets, roughly 1000 at the time being but that may expand to several thousand later. They are all开发者_如何学JAVA images but half of them are Animated GIFs so I can't import them at runtime. I considered simply dragging them into the flash project but I don't seem to have any control over the naming scheme. Basically, what I want to know is:
Is there a way to automate importing and renaming of flash assets, like "Import these 1000 files and export them for Actionscript with this name"?
Additionally, is there a better way for me to be doing this? I've tried http://code.google.com/p/as3gif/ AS3GIF but it struggles with larger animated gifs like the ones I'm working with (650x450). Any help would be appreciated.
Jsfl is your friend. Jsfl is Flash IDE script language, you can automate a lot of thing, for example, rename all lib clip :
function main()
{
var DOM = fl.getDocumentDOM();
var lib = DOM.library.getSelectedItems();
searchedClip = prompt("Search in clip name :");
if(searchedClip == null) return;
replaceClip = prompt("Replace by :");
if(replaceClip == null) return;
fl.outputPanel.clear();
nbRes = 0;
for(var i =0; i < lib.length; ++i)
{
name = lib[i].name.split("/");
name = name[name.length-1];
nIndex = name.toUpperCase().indexOf(searchedClip.toUpperCase());
if(nIndex != -1)
{
++nbRes;
fl.trace(lib[i].name);
lib[i].name = name.substring(0,nIndex) + replaceClip + name.substring(nIndex+searchedClip.length);
}
}
if(nbRes) fl.trace("\n"+nbRes+" results");
else fl.trace("no result");
}
main();
Look Flash IDE doc (http://livedocs.adobe.com/flash/9.0/main/flash_cs3_extending.pdf for CS3 Flash IDE Version)
If I remember right, if all the images are named like "image0", "image1" etc., when you add the first one to Flash, it'll say something like "It looks like this image is part of a sequence, do you want to import them all?". That'll take a bit of time though. Once they're in, you can shift-click to select them all to give them an export name (provided you don't want to change it, you can keep their name and it should be fine).
Why can't you load these at runtime again? Does Flash even playing animated gifs, so does that even matter? Exporting a SWF with that many images is going to kill your productivity and probably your computer (Flash gets a bit flaky when the file size gets huge). Waiting for that SWF to download on the client side would be a killer. Especially if your clients aren't going to be looking at all the images - you're throwing away MBs of bandwidth there.
I'd either load them at runtime (ideal - loading a compressed xml file is much quicker and easier), or if they absolutely had to be in the fla, i'd break it up into multiples.
精彩评论