NB. anche questo è da verificare
ho aggiunto i metodi "play", "pause" e "stop" all'oggetto... ponendo che tu abbia tre pulsanti che operano le scelte su elencate e che ne portino lo stesso nome di istanza, puo irichiamarli direttamente sui pulsanti in questo modocodice:var object:Object = new Object(); object.path = this; object.index = 1; object.paused = false; object.pausedPosition = 0; object.interval = new Number(); object.sound = new Sound(object.path); object.onLoadStart = function(){ this.interval = setInterval(this, "onLoadProgress", 20); this.sound.onLoad = function(ok){ if(ok){ this._parent["onLoadInit"](); } else { this._parent["onLoadError"](); } } this.sound.onSoundComplete = function(){ this._parent.index++; } }; object.onLoadProgress = function(){ trace(this.sound.getBytesLoaded()+" di "+this.sound.getBytesTotal()); }; object.onLoadError = function(){ this.index = 1; this.sound.loadSound(this.index+".mp3", false); }; object.onLoadInit = function(){ clearInterval(this.interval); this.sound.loadSound(this.index+".mp3", false); }; object.play = function(){ (!this.paused)? this.sound.start() : this.sound.start(this.pausedPosition, 1); } object.stop = function(){ this.pausedPosition = 0; this.paused = false; this.sound.stop(); } object.pause = function(){ this.pausedPosition = this.sound.position; this.paused = true; this.sound.stop(); } object.start = function(){ this.sound.loadSound(this.index+".mp3", false); }; object.start();
play.onRelease = object.play;
stop.onRelease = object.stop;
pause.onRelease = object.pause;

Rispondi quotando