Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-13-2008, 02:17 PM   #1
chrisnyc
Registered User
 
Join Date: May 2008
Posts: 4
Default Embed WAV file in Flex Builder 3 / ActionScript project?

I've built a game in Flex Builder 3 thinking it could do just about everything Flash CS3 can in a more developer-friendly environment. Everything was going great until I hit my head on the ceiling when I added audio to my project.

It seems the only supported embedded sound format is MP3, but MP3 is not suitable for loops because encoders add a few milliseconds of silence at the start and end of every MP3 track which kill the effect. The solution is to use WAV files for loops and I would love to do it, but it seems there's not provision in Flex Builder 3 or ActionScript 3 for embedding WAV files.

In Flash CS3 you can import WAV files to your library and bind them to objects, but I see no way to do anything like this in FB3.

Any suggestions, or am I at a dead end here?
chrisnyc is offline   Reply With Quote
Old 05-13-2008, 05:16 PM   #2
dr_zeus
Feathers
 
dr_zeus's Avatar
 
Join Date: Mar 2005
Location: Silicon Valley
Posts: 1,999
Default

Quote:
Originally Posted by chrisnyc View Post
MP3 is not suitable for loops because encoders add a few milliseconds of silence at the start and end of every MP3 track which kill the effect.
There should be a setting to turn that off in most encoders.
__________________
Josh Tynjala | Feathers
dr_zeus is offline   Reply With Quote
Old 05-13-2008, 05:16 PM   #3
chrisnyc
Registered User
 
Join Date: May 2008
Posts: 4
Default

Replying to myself in case anyone has the same question in the future and is searching for an answer.

I couldn't find any direct support for embedding WAV files in a Flex Builder 3 / ActionScript 3 application. What I did try and was delighted to see it works is to create a Flash Movie in Flash CS 3 (you will need to own that or get an evaluation) and import your sounds to the library and link them to be exported by ActionScript. Export the Flash CS3 project to a SWF movie and save it in your project (I added it to a "lib folder").

Your ActionScript code to create and play the sound should be:

ActionScript Code:
[Embed(source="lib/Sounds.swf", symbol="BigShipSound")] private static var BigShipSound: Class; ... var : bigShipSound : Sound = BigShipSound as Sound; bigShipSound.play(0, 20);
chrisnyc is offline   Reply With Quote
Old 05-13-2008, 05:23 PM   #4
dr_zeus
Feathers
 
dr_zeus's Avatar
 
Join Date: Mar 2005
Location: Silicon Valley
Posts: 1,999
Default

Oh wait, you said a few milliseconds. I thought it was seconds. Sounds like a crappy encoder. I've looped MP3s before no problem.
__________________
Josh Tynjala | Feathers
dr_zeus is offline   Reply With Quote
Old 05-13-2008, 06:26 PM   #5
chrisnyc
Registered User
 
Join Date: May 2008
Posts: 4
Default

I tried LAME and iTunes and both added silence to the MP3 problem. Whatever Flash CS3 does on export does not add silence.
chrisnyc is offline   Reply With Quote
Old 05-29-2008, 06:42 AM   #6
bugmenot
Banned by AS.org Staff
 
Join Date: Apr 2008
Posts: 14
Default

Thanks for posting your solution - I was facing the exact same issue and your method works great. Much appreciated!
bugmenot is offline   Reply With Quote
Old 09-04-2008, 01:55 AM   #7
skeetm0n
Registered User
 
Join Date: Jul 2008
Posts: 13
Default

very clever solution... but it still a hack and not very clean. there should be a nicer way to do this.
skeetm0n is offline   Reply With Quote
Old 09-04-2008, 02:15 AM   #8
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Maybe this page will help you create a seamless MP3 loop...
http://www.compuphase.com/mp3/mp3loops.htm
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 11-29-2012, 12:54 AM   #9
madhattter
Registered User
 
Join Date: Nov 2012
Posts: 2
Default Resultant filesize

Can anyone who has used chrisnyc's solution tell me how this impacts the filesize?

In other words, is the sound.swf approximately the size of the original wav, or does it get compressed? If it gets compressed, how does that compare to the size of the mp3 that you would have otherwise used?

Thanks a ton.
Ken
madhattter is offline   Reply With Quote
Old 11-29-2012, 04:47 PM   #10
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

I thought Flash encoded WAV to MP3 during the publish process. I think chrisnyc basically just ended up using Flash as a media encoder, and tossed a bit of unneeded bytecode on top. More efficient to just get a better encoder, I would think.

Last edited by drkstr; 11-29-2012 at 04:50 PM.
drkstr is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using swc in a flex project glidealong Flex 2, 3 & 4 1 02-04-2008 03:00 PM
Embed font in ActionScript with [Embed] traustid Flex 2, 3 & 4 1 01-29-2008 06:48 PM
NEW ActionScript 3 XIFF Version - for Flex Builder 2 projects with XMPP nickvelloff ActionScript 3.0 0 09-02-2006 03:12 AM
[Flex Builder 2] Adding Project References doesn't affect classpath? astgtciv Flex 2, 3 & 4 8 08-11-2006 10:57 PM
Import text directly into Actionscript from a Text file? waynedoz ActionScript 1.0 (and below) 2 03-11-2006 10:49 PM


All times are GMT. The time now is 09:47 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.