hi all,
Pardon my low knowledge and my cheap explanation …
when we assign a sound it’s like:
var Mysong:Sound;
and later we use it as
MySong.play();
But suppose we get a string like;
id:String;
and later that id is assigned a value;
id = MySong;
Now since there is also a sound named MySong, Is there a way I could play this String as a sound ?
I tried
id.play();
but failed
In short,is there a way I could use/get a sound by a string ?
saumya
October 14, 2017, 4:58pm
#2
In short, yes
Here is the sample code
var url:String = "path/to/sound.mp3"
var soundRequest = new URLRequest(url);
var mySound = new Sound(soundRequest);
Hope that helps
1 Like
Hazame
October 14, 2017, 6:06pm
#3
Maybe you can use StringMap?
var songs = new StringMap<Sound>();
songs.set('song_id', mySong);
And later:
var song = songs.get('song_id');
song.play();
1 Like
hi,
thanks very much for the replies
Interestingly both the solutions given worked and solved my problem!, ( while earlier i was frustrated about this problem before creating this topic)
it’s good for me as both the ways are working for me…
Thanks very much for your efforts!
anthony