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.
Code:// 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();




Reply With Quote