;

PDA

Click to See Complete Forum and Search --> : Audio Syncing


w.brants
04-02-2005, 12:11 PM
Here's an example of how multiple events could be added to a sound file. As you can see it can both set properties of an object and execute object functions with a supplied parameter array.
It may need some polishing but it's a start.


// Extending the sound object

Sound.prototype.setSoundEvents = function( events, accuracy ){
this.events = events;
this.current_event = 0;
if (this.interval_id != null) clearInterval(this.interval_id);
this.interval_id = setInterval(this, 'sync', accuracy);
}

Sound.prototype.sync = function(){
if (this.position >= this.events[this.current_event].sp){
var event = this.events[this.current_event];
if (event.f != null){
var func = event.o[event.f];
func.apply(event.o, event.p );
} else if (event.p != null){
event.o[event.p] = event.v;
}
this.current_event = this.current_event + 1;
if (this.current_event == this.events.length) clearInterval(this.interval_id);
this.sync();
}
}

// using it

mySoundEvents = new Array();

mySoundEvents.push ( { sp:1500, o:_root.mc1, f:'gotoAndStop', p:['eeks'] } );
mySoundEvents.push ( { sp:2000, o:_root.mc1, f:'gotoAndStop', p:[1] } );
mySoundEvents.push ( { sp:3000, o:_root.mc2, p:'_visible', v:false } );
mySoundEvents.push ( { sp:3500, o:_root.mc2, p:'_visible', v:true } );

mySoundEvents.sortOn('sp');

mySound = new Sound();
mySound.setSoundEvents( mySoundEvents, 50 ); accuracy 50 msec
mySound.loadSound('myMP3file.mp3',true);
mySound.start();

necromanthus
04-02-2005, 05:04 PM
The main problem is that because of the missing symbol-library (and the sound object) it doesn't work for internal sounds.
For loaded (external) sound files only.
Anyway, well done Wilbert.
;)

Bob Hartzell
04-03-2005, 08:57 AM
I'll start the implementation of a symbol library with sounds first.

necromanthus
04-04-2005, 06:56 AM
Originally posted by Bob Hartzell
I'll start the implementation of a symbol library with sounds first.
MovieClips are much more important.