-
How to do AS3 code for making the flvPlayback component mute without a skin
Hello there,
I've been struggling for days, and I had to have a project finished by just about this moment.
It is real simple, so I am probably real dumb..... but here is the deal:
* little banner 336x280
* I have a 2mb .FLV video embedded and synchonized in the timeline (which I know is not ideal)
* I only need a MUTE button to mute and unmute the sounds of the video at will
* also, the video is 52 seconds and must be looping constantly, but if you choose to MUTE the sound it should not go back on if the video (SWF) restarts
One way that worked for me to mute is the code below, but can't get it back on then:
import flash.media.SoundMixer;
import flash.events.MouseEvent;
audio_btn.addEventListener(MouseEvent.CLICK, btnMute);
function btnMute(e:MouseEvent):void{
SoundMixer.stopAll();
}
Any help within like yesterday would have given you 1000 Euro's, but anything within now and very soon will be celebrated at my place with a cold beer and EXTREMELY appreciated !!!
Best regards,
<( NOOB )>
JAMES, from Holland......
-
.
Hi,
As i was answering the question I noticed that it was for flv and not music.
Perhaps it will work for this too, try it.
I know it works for music
messa round with whats there.
PHP Code:
import flash.events.MouseEvent;
import flash.media.Sound; import flash.media.SoundMixer; import flash.media.SoundChannel; import flash.media.SoundTransform;
var soundChannel:SoundChannel = new SoundChannel();
var muted:Boolean = false; var soundVolume:Number; var soundControl:SoundTransform;
audio_btn.addEventListener(MouseEvent.CLICK, btnMute);
function btnMute(e:MouseEvent):void { if (muted) { soundVolume = 0;// 0 = no volume / muted } else { soundVolume = 1;// 1 = full volume } trace(soundVolume); soundControl = new SoundTransform(soundVolume); soundChannel.soundTransform = soundControl; muted = ! muted; }
Note: this does not stop the sound, only mutes it.
-
Hi Fruitbeard,
Thanks for the reply, doesn't do as advertised though
It does trace 1 and 0 nicely, but does not affect sounds, nor the embedded FLV, nor a sound file I specially loaded in to see if it was affected.
Note: I specifically need a MUTE, so that is good.
*** I did manage to solve my issue by using a skin and set the menu to UNDER the stage, this way I loaded a button on top op the location of the mute of the player.
Now it looks like my button is doing all the magic, but in fact is is the player hid under a picture.
Since the video height was lower than the stage, I could use this option.
*** One question regarding my fix;
Found that is should be possible to assign FLVPlayback component buttons, like follows: myFlvplayback.playButton=audio_btn;
This does not work, any ideas on this?
----------------------------------------------------------------------------------------------
None the less, I would still like to have the first idea possible for later projects.
So is there any adjustment to the script you know which might do the trick?
Because the script you sent seems to get REAL close......
James....
-
.
Hi,
Here it is for flv, or atl east its one way of doing it.
PHP Code:
import flash.events.MouseEvent;
import flash.media.SoundMixer;
var muted:Boolean;
var firstRun:String;
var newTransform:SoundTransform;
var vol:Number;
if (firstRun != "started")
{
trace("start");
muted = false;
vol = 1;
firstRun = "started";
newTransform = new SoundTransform();
newTransform.volume = vol;
SoundMixer.soundTransform = newTransform;
}
else
{
trace("Looped");
muted = muted;
vol = vol;
}
audio_btn.addEventListener(MouseEvent.CLICK, btnMute);
function btnMute(e:MouseEvent):void
{
muted = ! muted;
if (muted)
{
vol = 0;
}
else
{
vol = 1;
}
newTransform.volume = vol;
SoundMixer.soundTransform = newTransform;
}
Without seeing your naming system or set up, try that.
The firstRun part stops it from resetting all the vars again upon returning to frame 1.
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
|