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
----------------------------------------------------------
code
trace(this)code
on a given frame and it will return [object MainTimeline], but how do I start extract information from the timeline. Again, I'm fairly inexperience in AS3. – Brent