here is the code.

It was created by Branden J. Hall.

If you have question on it's use just e-mail me.

------------------------------------------
The only difference between Sound2 and Sound is the attachSound function.
When you call it with Sound2 you have to have an additional parameter, the
length of the sound in seconds.  That's it! With this thing you can do
pretty much everything you all have been asking for!

//--------------------------------------------------------------------------
-------------------
// Sound2 prototype object
//--------------------------------------------------------------------------
-------------------

//constructor
function Sound2(mc){
        this.sound = new Sound(mc);
        this.secs = 0;
        this.startTimer = null;
        this.pauseTimer = null;
        this.timer = 0;
        this.paused = false;
}

//stop
function Sound2_stop(id){
        this.startTimer = null;
        this.sound.stop(id);
}


//start
function Sound2_start(offset, loops){
        this.offset = offset;
        this.startTimer = getTimer() - (offset*1000);
        this.sound.start(offset, loops);
        this.duration = this.secs*(loops+1)*1000;
        trace(this.duration);
        this.loops = loops;
}

//pause
function Sound2_pause(){
        var currTime = getTimer();
        if (!this.paused){
                this.timer = currTime - this.startTimer;
                this.pauseTimer = currTime;
                this.paused = true;
                this.sound.stop(this.soundID);
        }else{
                this.paused = false;
                var tempStart = this.startTimer + (currTime -
this.pauseTimer);
                this.start(this.timer/1000);
                this.startTimer = tempStart;
        }
}

//attachSound
function Sound2_attachSound(soundID, secs){
        this.soundId = soundID
        this.secs = secs;
        this.sound.attachSound(soundID);
}


//isBusy
function Sound2_isBusy(){
        if (this.startTimer != null){
                if (getTimer() - this.startTimer < this.duration){
                        return (true);
                }else{
                        return (false);
                }
        }else{
                return (false);
        }
}

//timeElapsed
function Sound2_timeElapsed(){
        var currTime = getTimer();
        if (this.startTimer != null && (currTime - this.startTimer <
this.duration)){
                return ((currTime - this.startTimer)/1000);
        }else{
                return (-1)
        }
}

//timeRemaining
function Sound2_timeRemaining(){
        var currTime = getTimer();
        if (this.startTimer != null && (currTime - this.startTimer <
this.duration)){
                return ((this.duration - (currTime -
this.startTimer))/1000);
        }else{
                return (-1)
        }
}


//Build object and wrap other Sound methods as needed
Sound2.prototype.stop = Sound2_stop;
Sound2.prototype.start = Sound2_start;
Sound2.prototype.pause = Sound2_pause;
Sound2.prototype.attachSound = Sound2_attachSound;
Sound2.prototype.isBusy = Sound2_isBusy;
Sound2.prototype.timeElapsed = Sound2_timeElapsed;
Sound2.prototype.timeRemaining = Sound2_timeRemaining;
Sound2.prototype.getPan = function(){ return (this.sound.getPan())};
Sound2.prototype.getTransform = function(){ return
(this.sound.getTransform())};
Sound2.prototype.getVolume = function(){ return (this.sound.getVolume())};
Sound2.prototype.setPan = function(pan){ return (this.sound.setPan(pan))};
Sound2.prototype.setTransform = function(obj){ return
(this.sound.setTransform(obj))};
Sound2.prototype.setVolume = function(volume){ return
(this.sound.setVolume(volume))};
//--------------------------------------------------------------------------
-------------------


 Brian Douglas  (:ub)

============================================================================
AS/L/JS

6'2" 170lbs. eyes:bwn  hair:bwn  nose hair:well groomed

Imaginary Studio
212-239-4393 x 204


http://www.imaginarystudio.com --check it out!






[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to