Answered
JSFL - So does document.addFilter() just, like... not work?
Because it looks like it 100% doesn't work.
an.getDocumentDOM().addFilter("glowFilter");
an.trace(an.getDocumentDOM().getFilters().length); // 0
Because it looks like it 100% doesn't work.
an.getDocumentDOM().addFilter("glowFilter");
an.trace(an.getDocumentDOM().getFilters().length); // 0
i've tweaked the script to make it more robust, though it's just as silly as before. This one will work whether or not there's already artwork on the layer.
// This script applies a blue glow filter to the current layer.
// But it's a bit convoluted because of the way addFilter() works.
// You can't instantiate a filter out of thin air.
// So this script encapsulates the layer's artwork (if it exists)
// as a MovieClip to "protect it,"
// draws an oval, turns the oval into a movieClip, applies the glow,
// deletes the clip, and applies the glow to the layer.
// The reason why we don't just do this with the existing artwork is that
// the layer may not HAVE existing artwork. Hence the oval.
an.outputPanel.clear();
var dom = an.getDocumentDOM();
var tl = dom.getTimeline();
var layer = tl.layers[ tl.currentLayer ];
var frame = layer.frames[ tl.currentFrame ];
dom.selectAll();
if(dom.selected)
{
// Artwork already exists on this layer.
var doodleName1 = "doodle1234076894"; // Give it an improbable library name
var doodle1 = fl.getDocumentDOM().convertToSymbol("movie clip", doodleName1, "top left"); // Convert it to a MovieClip symbol
dom.selectNone(); // Deselect the MovieClip
}
dom.addNewOval({left:72,top:50,right:236,bottom:228}); // Draw an oval
frame.elements[ 0 ].selected = true; // Select the oval
var doodleName2 = "doodle78123456"; // Store an improbable library name for the oval
var doodle2 = fl.getDocumentDOM().convertToSymbol("movie clip", doodleName2, "top left"); // Convert the oval to a MovieClip
// Add a blue glow filter to the selected oval MovieClip:
dom.addFilter("glowFilter");
dom.setFilterProperty("blurX", 0, 24);
dom.setFilterProperty("blurY", 0, 24);
dom.setFilterProperty("strength", 0, 100);
dom.setFilterProperty("color", 0, "#00CCFF");
var filters = dom.getFilters(); // Get the list of filters on the currently selected stuff (the oval)
layer.setFiltersAtFrame(tl.currentFrame,filters); // Apply those filter(s) to the current layer
dom.deleteSelection(); // Delete the oval
dom.library.deleteItem(doodleName1); // Delete the oval from the library
if(dom.selected)
{
// There's artwork on the layer. so:
dom.selectAll(); // Select it
dom.breakApart(); // Break it out of a MovieClip symbol
dom.selectNone(); // Deselect it
dom.library.deleteItem(doodleName2); // Delete the temporarily encapsulated artwork from the library
}Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.