Copy link to clipboard
Copied
Hi,
I'm not sure if it's AS3 or Air /FB4 forum I should ask this:
I'm testing my air app on older notebook without sound drivers and problem is when I want to call SoundChannel.stop() function. Well I don't know what is the problem, I only managed to trace it to this line of code which calls stop() and now I don't know what to do since there was no error alert or nothing. Code just stops at this line.
I'm not even sure if it's problem with the sound driver.
I tried to look in google for answers and I found that play() function returns null when there is no drivers, but found nothing about stop() function.
Edit:
I've prepared sample application:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="init(event)">
<mx:Canvas width="500" height="500">
<mx:Text id="txt"/>
<s:Button id="btn" label="stop" click="btnClick(event)" bottom="0"/>
</mx:Canvas>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
private var snd:Sound = new Sound;
private var sndCtrl:SoundChannel = new SoundChannel;
protected function init(event:FlexEvent):void
{
snd = new Sound;
snd.addEventListener(Event.COMPLETE,sndLoaded);
var url:URLRequest;
url = new URLRequest("df1_fi1.wav");
snd.load(url);
}
private function sndLoaded(e:Event):void {
snd = e.target as Sound;
sndCtrl = snd.play();
}
protected function btnClick(event:MouseEvent):void
{
txt.htmlText += "before stop <br>";
sndCtrl.stop();
txt.htmlText += "after stop <br>";
}
]]>
</fx:Script>
</s:WindowedApplication>
Use any sound in place "df1_fi1.wav", export, install and lunch this app, then press the button. On computer with sound driver you can see "before" and "after" text on screen. On notebook without sound driver you can see only the "before" text.
Ok, I managed to install Flash Builder on this old laptop and debug this app.
Problem is that soundChannel is null on system without sound drivers. So every time I run sndCtrl.stop() there is a standard error of an empty object and system crashes.
I just need to make exceptions, like:
if (sndCtrl) sndCtrl.stop();
Copy link to clipboard
Copied
Ok, I managed to install Flash Builder on this old laptop and debug this app.
Problem is that soundChannel is null on system without sound drivers. So every time I run sndCtrl.stop() there is a standard error of an empty object and system crashes.
I just need to make exceptions, like:
if (sndCtrl) sndCtrl.stop();
Find more inspiration, events, and resources on the new Adobe Community
Explore Now