Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sound duration

Status
Not open for further replies.

jefargrafx

Instructor
May 24, 2001
273
US
hey guys,

I'm trying to use the sound property duration and position to change the background image of a MC.

when the sound is 25% done playing I want to tell another clip on the _root to gotoAndPlay frmae (2);

here's what I've tried

sound.onEnterFrame = function () {
if (sound.duration/4 == sound.position) {
_root.background_MC.nextFrame();
}
}

but it jsut sit there?

can do do this using onSoundComplete, but I want to change 4 time during the play back?

anyhelp?

jef
 
Try this... It's not exactly 25% but close enough!
Code:
mysound = new Sound(this);
mysound.loadSound("your.mp3");
mystart = 0;
mystep = Math.floor((mysound.duration/1000)/4);
mysound.start();

position_mc.onEnterFrame = function () {
if (Math.floor(mysound.position/1000) == (mystart+mystep)) {
    _root.background_MC.nextFrame();
    mystart +=mystep;
    }
    mysound.onSoundComplete = function() {
    if(mysound.position/1000 == (mysound.duration/1000)){
	delete this.onEnterFrame;
    }
    };
};

It uses a position_mc control movie clip off stage. Don't think it works when trying to assign it the sound object itself.



Regards,

cubalibre2.gif
 
nope...I did get it to work with the sound object duration and position.

useing a simalar onEnterFane event.

wasn't easy, or pretty, but it works,

thanks for the advice

jef
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top