LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-21-2008, 04:43 PM
FearShakenWorld FearShakenWorld is offline
Registered User
 
Join Date: Aug 2008
Posts: 4
Rep Power: 0
FearShakenWorld is on a distinguished road
xml mp3 player, I want it to stop playing when I change to a different frame

Hi guys, this is my first post. I hope someone can help out!

I have an xml mp3 player on a frame in the main timeline of my flash site called 'audio' I want the music to stop when I move to a different page (frame). At the moment the music continues on different pages of my site. I have tried several things but I'm a bit stumped now! Heres the code for the mp3 player:
Actionscript:
stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
    if (success) {
        _global.songname = [];
        _global.songband = [];
        _global.songfile = [];
        for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
            _global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
            _global.songband[i] = playlist.firstChild.childNodes[i].attributes.band;
            _global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
            // trace(songname[i]+"  "+songfile[i]+" "+songband[i]);
        }
    }
    _root.createEmptyMovieClip("sound_mc", 1);
    _global.song_nr = random(songfile.length);
    _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
function timer(sound_obj) {
    time = sound_obj.position/1000;
    min = Math.floor(time/60);
    min = (min<10) ? "0"+min : min;
    sec = Math.floor(time%60);
    sec = (sec<10) ? "0"+sec : sec;
    timeDisplay_txt.text = min+":"+sec;
}
MovieClip.prototype.songStarter = function(file, name, band) {
    if (this.sound_obj) {
        this.sound_obj.stop();
        delete this.sound_obj;
    }
    this.sound_obj = new Sound(this);
    this.sound_obj.loadSound(file, true);
    this.onEnterFrame = function() {
        if (this.sound_obj.position>0) {
            delete this.onEnterFrame;
            this._parent.display_txt.text = name+" / "+band;
            timeInterval = setInterval(timer, 1000, this.sound_obj);
        } else {
            this._parent.display_txt.text = "loading...";
        }
    };
    this.sound_obj.onSoundComplete = function() {
        clearInterval(timeInterval);
        this._parent.timeDisplay_txt.text = "00:00";
        (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
        _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
    };
    this._parent.volume1.dragger.onPress = function() {
        startDrag(this, true, 0, this._y, this._parent.volBG._width, this._y);
        this.onEnterFrame = function() {
            var p = (this._x/this._parent.volBG._width)*100;
            this._parent._parent.sound_mc.sound_obj.setVolume(p);
        };
    };
    this._parent.volume1.dragger.onRelease = function() {
        delete this.onEnterFrame;
        stopDrag();
    };
    this._parent.volume1.dragger.onReleaseOutside = function() {
        stopDrag();
    };
};
btn_play.onRelease = function() {
    clearInterval(timeInterval);
    this._parent.timeDisplay_txt.text = "00:00";
    this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
btn_stop.onRelease = function() {
    clearInterval(timeInterval);
    this._parent.timeDisplay_txt.text = "00:00";
    this._parent.sound_mc.sound_obj.stop();
};
btn_fw.onRelease = function() {
    clearInterval(timeInterval);
    this._parent.timeDisplay_txt.text = "00:00";
    (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
    _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
btn_rev.onRelease = function() {
    clearInterval(timeInterval);
    this._parent.timeDisplay_txt.text = "00:00";
    (song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
    _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
playlist.load("http://www.mysite.co.uk/mp3/playlist.xml");

Last edited by m. allen west : 10-21-2008 at 05:49 PM Reason: [AS]Tag your script please :p[/AS]
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mp3 player in external .swf FearShakenWorld Actionscript 2.0 0 10-22-2008 01:06 PM
MP3 player question Davegreen1 Flash 8 0 08-14-2007 12:48 PM
mp3 stops at scene change editionsix Newbies 9 10-01-2006 01:50 PM
MP3 Player v1.0Beta (Preview) Madokan Flash Components v0 6 06-01-2004 02:15 PM
JavaScript to Flash MP3 Player - Please Help!!! Vic D Flash MX ActionScript 1 11-11-2003 12:04 AM




All times are GMT. The time now is 08:42 PM.