Jump to content

Hey friends,

 

I'm coding a game for school and I'm nearly done with it, I just need to figure out how to loop a sound track. I don't know flash really well at all (this is my first project with it since freshman year) and I've been following a tutorial to code my game but it makes no mention of sound. 

 

So, that being said, can someone help me out here? I just want an mp3 file to loop over and over. I'm using Flash CS6 and Action Script 3.0. 

 

Thanks!

Corsair 5000D / Intel Core i7-12700KF / Arctic Liquid Freezer 3 360mm / MSI Meg Z690 Ace / RTX 3080 Ti Founder's Edition / 64GB Corsair Vengeance RGB 3200 MHz CL32 / Corsair RM1000X / 1TB ADATA SX8200 Pro (Boot) / 2TB Acer Predator GM7000 Gen 4 (Storage) / MSI MPG271QRX-QD / MSI Mag 274QRF-QD / LG CX 55" / G-Pro Wireless

Link to comment
https://linustechtips.com/topic/286590-flash-question-playing-music/
Share on other sites

Link to post
Share on other sites

According to the documentation you can just add a number (how many times it should loop) within the play() method.

play(startTime:Number = 0, loops:int = 0, sndTransform:flash.media:SoundTransform = null):SoundChannel

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#play()

 

 

Now i havent touched AS in a long long time but i guess you can do something like this

var s:Sound = new Sound();s.load(new URLRequest("file.mp3")); s.play(0, 9999);
Link to post
Share on other sites

 

According to the documentation you can just add a number (how many times it should loop) within the play() method.

play(startTime:Number = 0, loops:int = 0, sndTransform:flash.media:SoundTransform = null):SoundChannel

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#play()

 

 

Now i havent touched AS in a long long time but i guess you can do something like this

var s:Sound = new Sound();s.load(new URLRequest("file.mp3")); s.play(0, 9999);

 

Thanks for the reply!

 

How do I tell flash where my file is? I changed "file.mp3" to "depth.mp3" (the song I want to play, of course) and when I export the movie the game runs just fine, but no sound.

Corsair 5000D / Intel Core i7-12700KF / Arctic Liquid Freezer 3 360mm / MSI Meg Z690 Ace / RTX 3080 Ti Founder's Edition / 64GB Corsair Vengeance RGB 3200 MHz CL32 / Corsair RM1000X / 1TB ADATA SX8200 Pro (Boot) / 2TB Acer Predator GM7000 Gen 4 (Storage) / MSI MPG271QRX-QD / MSI Mag 274QRF-QD / LG CX 55" / G-Pro Wireless

Link to post
Share on other sites

Thanks for the reply!

 

How do I tell flash where my file is? I changed "file.mp3" to "depth.mp3" (the song I want to play, of course) and when I export the movie the game runs just fine, but no sound.

 

First make sure you have the packages you need imported (in the top of the file somewhere)

import flash.media.Sound;import flash.net.URLRequest;

then the depth.mp3 file should be located in the same directory as your swf file :)

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×