How to Trace Placement of Audio Files on Timeline in Flash

1.1k views Asked by At

I am working on an animation project. I'm not a programmer. I'm working in Flash CS3. I've an animation that I've produced that I need to output the placement of my audio track for use by the post-sound guy. After my recording session, my sound guy gave me one large file that had all my audio on it. I've had to scrub to the correct position on the audio track for each clip I wanted.

Now that my animation is completed, I've got my audio all in place, but I need a record of where it's at in the Flash Timeline so that I can give that to my post-sound guy so that he can rebuild it in his sound editing software.

What I'm wondering is if there is a way to run a trace or generate something of a text file that will do the following:

  1. list where the audio clip begins (key frame) on the main timeline (returns absolulte frame number from beginning of movie timeline)
  2. how long the clip plays for (number of frames)
  3. any notes on the key frame
  4. the symbol name/audio clip file name
  5. position within the audio clip file that is played in that selection.

I did a crash course in Actionscript 3.0 about 4 years back, but that's about the extent of my experience, so please be nice.

3

There are 3 answers

5
scriptocalypse On BEST ANSWER

Not from within ActionScript, no. Sounds on timelines are a notorious black-box that is full of nasty gotchas, among them being that you really have no way to know where a timeline sound "lives" at runtime. This might be something you can use a JSFL script to do, however. JSFL is a kind of "Javascript" that lets you manipulate and examine the .fla contents, as well as output messages to the trace window.

Just to be clear, JSFL is something that you execute against the flash authoring tool itself, during "authoring time". It is not a runtime language. It does not apply to swf files.

Here's the docs on JSFL.

http://help.adobe.com/en_US/Flash/10.0_ExtendingFlash/WS5b3ccc516d4fbf351e63e3d118a9024f3f-7fe8.html

2
Ribs On

Its hard to tell exactly how you have this all set up but based on what you have said I'd try something like this. Place the following code on the first frame of your animation timeline:

var movieFrameRate:Number = 20;  //frame rate of your movie
var totalFramesOfMovie:Number = this.totalFrames;

var startingFrameOfSoundClip:Number;
var endingFrameOfSoundClip:Number;

var startingMilSecsOfSoundClip:Number;
var endingMilSecsOfSoundClip:Number;

var currentClipName:String;

function findMilSecsFromStart(startingFrameOfSoundClip:Number):Number
{
    var MilSecs:Number = (startingFrameOfSoundClip / movieFrameRate) * 1000;

    return MilSecs;
}

function findFramesFromStart(startingFrameOfSoundClip:Number):Number
{
    var frames:Number = startingFrameOfSoundClip;

    return frames;
}

function durationInFrames(startingFrame, endingFrame):Number
{
    var durationInFrames:Number = endingFrame - startingFrame;

    return durationInFrames;
}

function durationInMilliseconds(startingFrame, endingFrame):Number
{
    var durationInMilSecs:Number = ((endingFrame - startingFrame) / movieFrameRate) * 1000;

    return durationInMilSecs;
}


function collectInitialInfo():void
{
    trace("Clip Name: " + currentClipName);
    trace("Number of frames from beginning: " + findFramesFromStart(startingFrameOfSoundClip));
    trace("Time from beginning in MilSecs: " + findMilSecsFromStart(startingFrameOfSoundClip));
}

function collectFinalInfo():void
{
    trace("Duration of sound clip in frames: " + durationInFrames(startingFrameOfSoundClip, endingFrameOfSoundClip));
    trace("Duration of sound clip in milSecs: " + durationInMilliseconds(startingFrameOfSoundClip, endingFrameOfSoundClip));
    trace("----------------------------------------------------------");
} 

Then on each frame where a sound clip starts place the following, where mySoundClip_1 is always the instance name of the sound clip starting there:

currentClipName = 'mySoundClip_1';
startingFrameOfSoundClip = this.currentFrame;
collectInitialInfo();

and then on each frame where a sound ends, place the following code:

endingFrameOfSoundClip = this.currentFrame;

collectFinalInfo();

I have made a timeline, with multiple instances of a simple movieclip of a square to mimic the placement of sound clips as you have described, with instance names mySoundClip_1, mySoundClip_2 etc.

I have tested it and it generates the following trace in the output window:

Clip Name: mySoundClip_1
Number of frames from beginning: 4
Time from beginning in MilSecs: 200
Duration of sound clip in frames: 35
Duration of sound clip in milSecs: 1750
----------------------------------------------------------
Clip Name: mySoundClip_2
Number of frames from beginning: 75
Time from beginning in MilSecs: 3750
Duration of sound clip in frames: 55
Duration of sound clip in milSecs: 2750
----------------------------------------------------------
Clip Name: mySoundClip_3
Number of frames from beginning: 179
Time from beginning in MilSecs: 8950
Duration of sound clip in frames: 18
Duration of sound clip in milSecs: 900
----------------------------------------------------------
Clip Name: mySoundClip_4
Number of frames from beginning: 219
Time from beginning in MilSecs: 10950
Duration of sound clip in frames: 56
Duration of sound clip in milSecs: 2800
----------------------------------------------------------
Clip Name: mySoundClip_5
Number of frames from beginning: 289
Time from beginning in MilSecs: 14450
Duration of sound clip in frames: 32
Duration of sound clip in milSecs: 1600
----------------------------------------------------------
0
Justin Putney On

JSFL is probably the best way to do this.

You can create a new JSFL file with File > New... > Flash JavaScript File.

You can then run the script using the play button in the Script Editor.

This help page shows the common locations for the Configuration directory if you'd like to save your script as a Command.

I'm also putting together a series of tutorials that might be helpful:

Here's a sample script that will output the locations of audio in the current Timeline of the current document:

fl.outputPanel.clear();
var dom = fl.getDocumentDOM();
fl.trace('Timeline sound for ' + dom.name);
fl.trace('-------------------');
var divider = ' \t\t ';
var tl = dom.getTimeline();
for(var i=0; i < tl.layerCount; i++){
    var tLayer = tl.layers[i];
    for(var j=0; j < tLayer.frameCount; j++){
        var tFrame = tLayer.frames[j];
        if(tFrame == undefined) {
            break;
        }
        if(tFrame.startFrame == j) { //only run on keyframes
            if(tFrame.soundLibraryItem != null && tFrame.soundName.length > 0) {
                var seconds = j * dom.frameRate;
                //output info
                fl.trace('layer: ' + tLayer.name + divider + 'start (frame): ' + j + 1 + divider + ' start (sec): ' + seconds + divider + 'sound file: ' + tFrame.soundName);
            }
        } else { //skip to next keyframe
            j = tFrame.startFrame + tFrame.duration - 1;
            continue;
        }
    }
}
fl.trace('-------------------');
fl.trace('Output complete.');

The output will look something like this:

Timeline sound for testAudio2.fla
-------------------
layer: audio 2   start (frame): 31    start (sec): 36    sound file: BUMMER.WAV
layer: audio 2   start (frame): 131       start (sec): 156   sound file: COOL_F.WAV
layer: audio 2   start (frame): 411       start (sec): 492   sound file: preparetodie.wav
layer: audio 2   start (frame): 2721      start (sec): 3264      sound file: mcc_hello.mp3
layer: audio 2   start (frame): 2971      start (sec): 3564      sound file: mcc_seriously.mp3
layer: audio 2   start (frame): 3301      start (sec): 3960      sound file: point.wav
layer: audio 2   start (frame): 4321      start (sec): 5184      sound file: happy5.wav
-------------------
Output complete.

Customize as you see fit. You would need to modify it if you want to search all Timelines or multiple documents, for instance.