actionscript - Flex: how to change the volume of an EMBEDDED sound? -
searching how change volume of sounds, irritating snd=new sound(urlrequest)
, followed snd.setvolume(val)
. oh, fine, sound not urlrequest, it's embed.
i've made lot of random attempts (1) no avail. how supposed instead?
(1) including casting class sound, creating sound embed class argument, creating soundtransform , setting channel, etc.
instantiate embedded class this:
[embed(source="mysound.mp3")] public var soundclass:class; protected function application1_creationcompletehandler(event:flexevent):void { var smallsound:sound = new soundclass() sound; var trans:soundtransform = new soundtransform(.01); smallsound.play(0,0,trans); }
update:
in case wanted know how change volume if sound playing:
[embed(source="mysound.mp3")] public var soundclass:class; public var smallsound : sound; public var vol : number = 0.01; public var trans : soundtransform; public var chan : soundchannel = new soundchannel(); protected function application1_creationcompletehandler(event:flexevent):void { smallsound = new soundclass() sound; trans = new soundtransform(vol); chan = smallsound.play(0,0,trans); } protected function volup_clickhandler(event:mouseevent):void { vol += .1; trans = new soundtransform(vol); chan.soundtransform = trans; }
Comments
Post a Comment