You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by scott matheson <sc...@matheson.it> on 2015/12/03 23:05:00 UTC
SoundEffect, reload an IO_ERROR
Hi
We have been looking at this for some time and can not find a solution,
when using soundEffect, if we pick up an IO_ERROR most often due to network issue, we would like to try and re-load the the sound, but we can not seem to get this to work, maybe we are just taking the wrong approach ?
this is our code, this code is part of an item render
package com.peach.uofs.common
{
import com.peach.Analytics;
import com.peach.uofs.model.UofSModel;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.utils.getQualifiedClassName;
import mx.effects.SoundEffect;
import mx.logging.ILogger;
import mx.logging.Log;
public class UofSSoundEffect extends SoundEffect
{
public var _uofsModel:UofSModel = UofSModel.getInstance();
public function UofSSoundEffect(target:Object=null)
{
this.instanceClass = UofSSoundEffectInstance;
super(target);
logger = Log.getLogger(getQualifiedClassName(this).replace('::', '.'));
this.source = whitespace;
}
private var logger:ILogger;
private var fileSize:Number;
[Embed(source="whitespace.mp3", mimeType="audio/mpeg")]
private var whitespace:Class;
private var queueTime:Date = new Date();
private var startDownloadTime:Date;
private function handleSoundDownloadError(event:IOErrorEvent):void {
event.preventDefault();
event.stopImmediatePropagation();
if (this.source is String) {
logger.error("[error] sound could not download url=" + this.source.toString());
>> want to reload at this point
} else {
logger.error("[error] some sort of non URL sound went wrong");
}
>> we try to fix the issue, by replacing the sound with a local emebed sound
>> this does not wormk
this.source = whitespace;
}
override public function load():void
{
super.load();
this.addEventListener(IOErrorEvent.IO_ERROR, handleSoundDownloadError);
}
}