Using MP3 sound files in pure AS3 project

Answered

I have an AS3 project that uses 8 sound files (MP3's). If I put these files in the bin and use, the first sound (Sound1.mp3) will play in a test:

var s1:Sound = new Sound(new URLRequest("C:\\Users\\me\\Desktop\\build\\xyz-6\\bin/Sound1.mp3"));
s1.play();

My questions:

(1) how do you include these 8 sound files in the project? (2) how do you use a relative path instead of an absolute path? (3) Is there a better AS3 script to import and use these sound files?

Thank you for your help.

0
6 comments

> (1) how do you include these 8 sound files in the project?

Not sure I understand the question. I could say 'just locate these files in the project folder", but I guess that's not the answer you are looking for.

> (2) how do you use a relative path instead of an absolute path?

Is this question related to the IDE? It sounds more like an ActionScript API related one.

> (3) Is there a better AS3 script to import and use these sound files?

This question also sounds like not related to the IDE. I'm afraid I'm not an experienced AS3 developer.

0

I think if I could use a relative path to the folder, this would be helpful. Maybe I can find an AS3 script that gets the relative path to the folder where the project would be installed on a user's computer/device?

Re: including the sound files, I thought that maybe there is an IntelliJ dialog that allows a file to be included as a dependency?

0

What kind of app are you developing?

0

I think that I found the answer: if the sound file is located in the same folder as the SWF,

and the path is

new Sound(new URLRequest("/Sound1.mp3");

it plays OK.

 

0

Ok, so now I've got an idea about the project type and probably can give you a better answer.

You need to place resource files in the source folder (usually it is ProjectRoot/src), this way on compilation IDE will copy it to the output folder next to the swf file.

0

Thank you. I'll try this.

0

Please sign in to leave a comment.