|
-
loading sounds with urlrequest, i dont understand.
in this piece of code:
PHP Code:
var mySoundReq:URLRequest= new URLRequest("samplesound.mp3");
var mySound:Sound = new Sound();
mySound.load(mySoundReq);
How does the urlrequest know where that .mp3 file is located, and how do i tell as3 where it is?
and another thing: when i put this on the web, how do i locate the file then?
-
In that scenario, "samplesound.mp3" is a relative URL, indicating that the file samplesound.mp3 is in the same directory as the swf file.
-
what if its not in the same file, or if it's a nested file? i cant seem to get it to work.
and what if it's on the internet?
-
Not in the same file, in the same directory. It corresponds to a directory structure like this:
parentfolder
movie.swf
samplesound.mp3
If your samplesound is in a subdirectory, say "sounds", like this:
parentfolder
movie.swf
sounds
samplesound.mp3
then your urlrequest would change to this:
Code:
var mySoundReq:URLRequest= new URLRequest("sounds/samplesound.mp3");
On the internet, it's exactly the same, as long as the structure appears the same to the browser.
-
ah i get it ok. but what if the movie.swf is in a subfolder of the folder that contains the filder that contains the sound-files?
and what if you want to use a class for multiple .fla files, that are at different folders?
-
 Originally Posted by omniscient232
ah i get it ok. but what if the movie.swf is in a subfolder of the folder that contains the filder that contains the sound-files?
Like this?:
parentfolder
samplesound.mp3
swfs
myMovie.swf
Then you use ".." to traverse the hierarchy upward
Code:
var mySoundReq:URLRequest= new URLRequest("../samplesound.mp3");
and what if you want to use a class for multiple .fla files, that are at different folders?
Then you do not hardcode the url. Pass it in as an argument. Or you could use an absolute url, but that will change between local and internet deployment
Code:
var mySoundReq:URLRequest= new URLRequest("http://mysite.com/sounds/samplesound.mp3");
-
that makes sense. thanks alot!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|