Search code examples
flasheditbatch-processingmaya

How to batch edit shapes of a swf animated movieclip?


For a flash game project I have swf animated clips generated through 3D rendering soft (i.e Maya Vector Renderer). Now I need to isolate parts of the clips (character's body, armor, sword, etc.) in individual multiframe clips. But I need these clips to be masked by character's body (e.g when sword swings behind body it should be cropped, so I can keep the sword's animation clip in front of the body clip even when the sword swings actually behind the body...)

To do this I am using a kind of traditional sfx technique: I render every items (e.g the sword) on a plain green background, and also with the character's body having the same green shader. Then I just have to erase the green shape on every frames of the clips in Flash. The problem is that I am going to have a lot of clips, each with a lot of frames... Is there a way to batch edit this using flash or any software? Or anyone can think of a more convenient way to do this?


Solution

  • If you have a transparent background png, try bringing one of them in to flash and bitmap tracing it. This should leave you with just your object, saving you the 'erasing green shapes' step on every frame.

    If this is acceptable/what you want, then what you can do is import a whole ton of frames in to the timeline as a movieclip, then use a jsfl script to bitmap trace all of them at once.

    Here is a jsfl script I've written that can trace bitmaps spread over many frames (where there is 1 bitmap per frame). Copy the contents and save it as a jsfl file.

    To run it, import a bunch of pngs into the timeline and select all the frames they are in. Then go to "Commands" -> "Run Command" to trace each bitmap in the selected frames.

    var timeline = fl.getDocumentDOM().getTimeline();
    
    // get selected frame numbers
    var selectedFrameObject = timeline.getSelectedFrames();
    
    var start = selectedFrameObject[1];
    var end = selectedFrameObject[2];
    
    fl.trace("Selected frames: "+ start +"-"+ end);
    
    for(var counter = start; counter < end; counter++){
        timeline.currentFrame = counter;
        document.selectAll();
        // you can play with these values to change the tracing parameters
        document.traceBitmap(100, 8, "normal", "many corners");
        document.selectNone();
    }