Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash JSFL:删除与特定颜色匹配的所有笔划?_Flash_Jsfl - Fatal编程技术网

Flash JSFL:删除与特定颜色匹配的所有笔划?

Flash JSFL:删除与特定颜色匹配的所有笔划?,flash,jsfl,Flash,Jsfl,我正在寻找一个jsfl函数,它可以选择帧上的所有项目,并删除与特定颜色(如0000ff)匹配的所有笔划 基本上,我用铅笔工具用红色铅笔笔划做了很多笔记。但当我完成后,我只想告诉flash从屏幕上删除我所有的红色斯托克斯,其他一切都完好无损。有什么解决办法吗?好问题 查看JSFL文档中的Document对象,我发现检索笔划的唯一方法是通过Document.getCustomStroke,这很烦人。理想情况下,形状对象将存储笔划和填充信息,但它不会: 我尝试使用数组控制选择: var doc = f

我正在寻找一个jsfl函数,它可以选择帧上的所有项目,并删除与特定颜色(如0000ff)匹配的所有笔划

基本上,我用铅笔工具用红色铅笔笔划做了很多笔记。但当我完成后,我只想告诉flash从屏幕上删除我所有的红色斯托克斯,其他一切都完好无损。有什么解决办法吗?

好问题

查看JSFL文档中的Document对象,我发现检索笔划的唯一方法是通过Document.getCustomStroke,这很烦人。理想情况下,形状对象将存储笔划和填充信息,但它不会:

我尝试使用数组控制选择:

var doc = fl.getDocumentDOM();
doc.selectAll();
var s = new Array().concat(doc.selection);
var sl = s.length;
doc.selectNone();

for(var i = 0; i < sl ; i++){
   doc.selection = s[i];
   stroke = doc.getCustomStroke('selection')
   fl.trace(stroke.color)
}
但这不是很有帮助,因为笔记可以有任何形状, 因此,在便笺左上角单击可能会错过一次 选择 循环通过每个像素只是为了得到一个选择是行不通的

简短的回答不是因为检索笔划颜色的唯一方法 是通过文档选择的

不过,有一些变通办法:

在IDE中,使用查找和替换,选择颜色而不是文本 并用透明的颜色替换您的便笺。不幸地 这不是一个很好的解决方案。它只会隐藏注释,而不会删除它们。 资料来源:

使从jsfl获取注释变得容易:将所有注释放在当前 将时间线放在一个层中,并给它起一个提示性的名称,说“_notes”,然后 删除该层

e、 g

希望有人能提供一个在jsfl中通过颜色选择对象的好方法。在IDE中可以做很多事情,但是:


HTH

我最近需要处理一些旧的FLA文件,并且不得不做一些类似的事情。 下面的代码将在当前文档的所有层和框架中找到所有匹配的笔划。 在Flash CS6中测试

请注意,这不会将文档标记为已修改,因此您需要以某种方式修改文档才能保存

var dom = fl.getDocumentDOM();
var timeline = dom.getTimeline();

/*
 MODIFY THE KEYS IN THIS TABLE.
 */
var coloursToDelete = {
    'FF0000': true,
    'FFFF00': true,
};

var replacements;
var srcColour;
var layerName;

// Make sure all colours are lowercase and start with a #
for(var colour in coloursToDelete)
{
    var val = coloursToDelete[colour];
    delete coloursToDelete[colour];
    
    if(colour[0] !== '#')
        colour = '#' + colour;
    
    coloursToDelete[colour.toLowerCase()] = val;
}

// Make sure to clear the selection, or the script will crash?
dom.selectNone();

fl.outputPanel.clear();

var deleteCount = 0;

// ----------------------------------------------------
// Loop through all layers
for(var layerIndex in timeline.layers)
{
    var layer = timeline.layers[layerIndex];
    
    if(!layer.visible)
        continue;
    
    // ----------------------------------------------------
    // Loop through all frames of the current layer
    for(var frameIndex = 0; frameIndex < timeline.frameCount; frameIndex++)
    {
        var frameDeleteCount = 0;
        var frame = layer.frames[frameIndex];
        
        if(!frame)
            continue;
        
        // ----------------------------------------------------
        // Loop through all elements in the current frame
        for(var elementIndex in frame.elements)
        {
            var element = frame.elements[elementIndex];
            
            if(!element)
                continue;
            
            if(element.elementType !== 'shape')
                continue;
            
            // ----------------------------------------------------
            // Check each edge in the current shape
            for(var edgeIndex in element.edges)
            {
                var edge = element.edges[edgeIndex];
                var stroke = edge.stroke;
                var fill = stroke ? stroke.shapeFill : null;
                
                if(!fill)
                    continue;
                
                if(fill.color in coloursToDelete)
                {
                    stroke.shapeFill = null;
                    edge.stroke = fill;
                    deleteCount++;
                    frameDeleteCount++;
                }
            }
        }
        
        // A quirk of deleting strokes like this is that shapes won't automatically merge like they would when deleting a stroke in the editor.
        // Selecting then deselecting will force this to happen
        if(frameDeleteCount > 0)
        {
            dom.selectAll();
            dom.selectNone();
        }
    }
}

fl.trace('-- ' + dom.name + ': Deleted ' + (deleteCount) + ' strokes.');

是的,这似乎应该是一个非常基本的操作,但基于jsfl本身的功能,这似乎是不可能的。@Ibis jsfl有时会很烦人。很高兴看到flashfilmmaker.com网站充满活力,顺便说一句:
var doc = fl.getDocumentDOM();
if(!doc) alert('Pardon me! There is no document open to work with.');

fl.trace(deleteLayerByName('_notes'))

/*Returns true if the layer was found and deleted, otherwise returns false*/
function deleteLayerByName(name){
    var timeline  = doc.getTimeline();
    var frame     = timeline.currentFrame;
    var layers    = timeline.layers;
    var layersNum = layers.length;
    for(var i = 0 ; i < layersNum; i++){
        if(layers[i].name == name){
            timeline.deleteLayer(i)
            return true;
        }
    }
    return false;
}
var dom = fl.getDocumentDOM();
var timeline = dom.getTimeline();

/*
 MODIFY THE KEYS IN THIS TABLE.
 */
var coloursToDelete = {
    'FF0000': true,
    'FFFF00': true,
};

var replacements;
var srcColour;
var layerName;

// Make sure all colours are lowercase and start with a #
for(var colour in coloursToDelete)
{
    var val = coloursToDelete[colour];
    delete coloursToDelete[colour];
    
    if(colour[0] !== '#')
        colour = '#' + colour;
    
    coloursToDelete[colour.toLowerCase()] = val;
}

// Make sure to clear the selection, or the script will crash?
dom.selectNone();

fl.outputPanel.clear();

var deleteCount = 0;

// ----------------------------------------------------
// Loop through all layers
for(var layerIndex in timeline.layers)
{
    var layer = timeline.layers[layerIndex];
    
    if(!layer.visible)
        continue;
    
    // ----------------------------------------------------
    // Loop through all frames of the current layer
    for(var frameIndex = 0; frameIndex < timeline.frameCount; frameIndex++)
    {
        var frameDeleteCount = 0;
        var frame = layer.frames[frameIndex];
        
        if(!frame)
            continue;
        
        // ----------------------------------------------------
        // Loop through all elements in the current frame
        for(var elementIndex in frame.elements)
        {
            var element = frame.elements[elementIndex];
            
            if(!element)
                continue;
            
            if(element.elementType !== 'shape')
                continue;
            
            // ----------------------------------------------------
            // Check each edge in the current shape
            for(var edgeIndex in element.edges)
            {
                var edge = element.edges[edgeIndex];
                var stroke = edge.stroke;
                var fill = stroke ? stroke.shapeFill : null;
                
                if(!fill)
                    continue;
                
                if(fill.color in coloursToDelete)
                {
                    stroke.shapeFill = null;
                    edge.stroke = fill;
                    deleteCount++;
                    frameDeleteCount++;
                }
            }
        }
        
        // A quirk of deleting strokes like this is that shapes won't automatically merge like they would when deleting a stroke in the editor.
        // Selecting then deselecting will force this to happen
        if(frameDeleteCount > 0)
        {
            dom.selectAll();
            dom.selectNone();
        }
    }
}

fl.trace('-- ' + dom.name + ': Deleted ' + (deleteCount) + ' strokes.');