Fix Textfields JSFL
Today Seb was having some issues when dealing with embedded fonts – read his post. He came up with some ActionScript ways to get around it. Well another way would be to use JSFL. A couple of my team members at Fuel Industries wrote the following JSFL script. It goes through your library and searches out any dynamic textfields. Once it finds one it makes sure it’s on a whole pixel, turns the auto kern off, embeds “UpperCase, LowerCase, Numerals, Punctuation” characters, and makes it not selectable. But you could make it do pretty much anything you can through JSFL.
fl.outputPanel.clear(); scanLibrary(fl.getDocumentDOM().library); function getIsWholeInt(n) { var s = String(n); if(s.indexOf(".") != -1) { return false; } else { return true; } } function round(n) { var s = String(n); var a = s.split("."); var num = parseInt(a[0]); var dec = parseInt(a[1].substr(0, 1)); if(dec >= 5) { num++; } return num; } /** * Scans the supplied flash library for linked classes and makes sure the textfields are set up properly * @param library A flash library to scan. */ function scanLibrary(library) { var items = library.items; var item; var replaceCount = 0; for( var i = 0; i < items.length; i++ ) { item = items[i]; if (item.itemType == 'movie clip') { var timeline = item.timeline; var h = timeline.layerCount; library.selectItem(item); library.editItem(); while(h--) { var k = timeline.layers[h].frameCount; while(k--) { var j = timeline.layers[h].frames[k].elements.length; while(j--) { var elems = timeline.layers[h].frames[k].elements; var p = elems.length; while(p--) { if(elems[p].elementType == "text" && (elems[p].textType == "dynamic" || elems[p].textType == "input")) { //Change the Static Text Fields to Dynamic if(elems[p].textType == "static") { elems[p].textType = "dynamic"; } //Handle all Dynamic TextFields if(elems[p].textType == "dynamic") { //Remove the ability to be selectable elems[p].selectable = false; } //Handle all Dynamic or Input Textfields //Remove the auto kern attribute elems[p].setTextAttr('autoKern', false); //Embed fonts UpperCase, LowerCase, Numerals, Punctuation elems[p].embedRanges = "1|2|3|4"; //Pop onto whole pixel var matX = elems[p].matrix; var x = matX.tx; if(!getIsWholeInt(x)) { matX.tx = round(x); elems[p].matrix = matX; } var matY = elems[p].matrix; var y = matY.ty; if(!getIsWholeInt(y)) { matY.ty = round(y); elems[p].matrix = matY; } } } } } } } } }
Continue reading » · Written on: 08-24-09 · 4 Comments »

Off-topic – but for some reason in your RSS in google reader, i get the following content:
“Pilex For Sale Cordarone No Prescription Buy Adalat No Prescription Buy Lamictal Online Buy Online Clarina Glucophage For Sale Sinequan No Prescription Buy Levitra No Prescription Buy Online Tramadol Lioresal For Sale Buy Zetia Online Buy Acomplia No Prescription Prandin No Prescription Buy Online Viagra Avodart For Sale Buy Superman Online Buy Loprox No Prescription High Love No Prescription Buy Online Deltasone Buy Isordil Online Emsam No Prescription Zestril For Sale Buy Requip No Prescription Buy Online Sleepwell Bu”
What’s up with that?
/dan
August 24th, 2009 at 9:27 pmHi,
thanks for the script. Could it be, that the index variable ‘j’ is never used and thus the whole while loop for ‘j’ is superfluous?
Thanks and cheers
November 10th, 2009 at 6:50 amSven
Just wanted to say thanks for the script – in 5 minutes I had managed to hack it to clean out the missing font references that were crashing my CS4 every time I tried to publish my project.
April 13th, 2010 at 11:29 am@Glen
Glad it worked out for you.
Julian
April 13th, 2010 at 3:29 pm