Your code looks fine apart from where you set up the var snd.

I have similar code that I used to test an embedded sound and I've used 

public var snd:SoundAsset = new sndCls as SoundAsset;

and that works fine, so just drop the () from sndCls and all should be
well.

 

Also make sure that your mp3 file is in the same folder as the MXML
file.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of not me
Sent: 01 January 2007 01:53
To: [email protected]
Subject: [flexcoders] Embed Sounds

 

Dear all,

I'm a Flex newbie. I have tried Flex Builder 2 Sample for embed
sounds. it should be like this :

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> ">

<mx:Script>
<![CDATA[

import flash.media.*; 

[Embed(source="mySound.mp3")]
[Bindable]
public var sndCls:Class;

public var snd:SoundAsset = new sndCls() as SoundAsset; 
public var sndChannel:SoundChannel;

public function playSound():void {
sndChannel=snd.play();
} 
public function stopSound():void {
sndChannel.stop();
} 
]]>
</mx:Script>

<mx:HBox>
<mx:Button label="play" click="playSound();"/>
<mx:Button label="stop" click="stopSound();"/>
</mx:HBox>
</mx:Application>

I think it would be run properly. But, when i run the code, there's an
error founded.

"unable to resolve 'mySound.mp3' for transcoding"

I have tried another example for embed the sounds, but the error was
same. always in the embed declaration.

any one know, who to Embed the sounds in adobe flex ?
i'm very appreciate for the help.

thx
Sutuy

 

Reply via email to