draw {
url:Embed(source="Assets/Sound/Active.mp3");
}
Refer this
Pergunta
I am trying to use sound in flex. I got the output using urlrequest, as I have less sound files to use, and need not to load everytime i call it. So I tried to put that in css and use it, but I am getting an error : TypeError: Error #1007: Instantiation attempted on a non-constructor.
Below is my code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Style>
draw
{
url:"Assets/Sound/Active.mp3";
}
</mx:Style>
<mx:Script>
<![CDATA[
import flash.media.Sound;
import flash.media.SoundTransform;
internal var sound:Sound;
internal var soundVolume:SoundTransform;
public function playSound():void
{
var SoundClass:Class;
try
{
SoundClass = StyleManager.getStyleDeclaration("draw").getStyle("url") as Class;
soundVolume = new SoundTransform(1, 0);
trace("sound : "+sound);
sound = new SoundClass() as Sound;
sound.play(0, 0, soundVolume);
}
catch(E:Error)
{
trace("E "+E);
}
}
]]>
</mx:Script>
<mx:Button click="playSound()" label="Discard"/>
</mx:Application>
Solução
draw {
url:Embed(source="Assets/Sound/Active.mp3");
}
Refer this