flash (macromedia):
I am making a CD in which we load a number of mp3 files. I sequences the mp3 files dynamically by passing an array of mp3 file names to the function. The function simply plays the first sound and on the event "onSoundComplete" it loads the next sound in the array. The functions behaves and infact stop working if it does not find the file to be loaded. This is reported as an error in authoring environment but not in the flash player or whent it run as standalone. Is there any method to prompt the user for the missing file. Attached is the code for sequencing the mp3 files: class soundSequencer { var snd:Array; var curSndID:Number; var data0:Sound; //Constructor public function soundSequencer(snd:Array) { this.snd = snd; } function createSoundSequence() { _root.soundsequencecomplete = false; var len = this.snd.length; for (var i = 0; i<=len; i++) { this["data"+i] = new Sound(); this["data"+i].ivar = i; this["data"+i].onLoad = function(success) { this.stop(); }; this["data"+i].loadSound("sound/"+snd[i], true); this["data"+i].onSoundComplete = function() { if ((this.ivar+1) == len) { _root.soundsequencecomplete = true; _root.loadNextModule(); } else { _root.check.gotoAndPlay(2); } }; } } //this plays the sound refered to the id-1 public function playSound(id) { this["data"+(id)].start(); } }
this["data"+i].onLoad = function(success) { if(success){ this.stop(); }else{ //do whatever you want when the sound does NOT load }
Now I jus want to prompt the name of sound file. I try mx.controls.Alert.show(this.ivar+":"+snd) which gives output in window (say for the sound file at index 1) 1:undefined
I haven't worked with classes, but doesn't the path to snd change within the onLoad? Try: this["data"+i] = new Sound(); this["data"+i]._parent = this; Then, you could use: this._parent.snd inside the Alert.show
Don't see what you're looking for? Try a search.
|