Help - Search - Member List - Calendar
Full Version: disabling button hit state
WorkTheWeb Forums > Webmaster Resources > Macromedia Flash
Support our Sponsors!
Dwayne Epps
I've been working on a button audio toggle that I finally have working okay.
One problem I'm still trying to solve is disabling the hit state for each
button when it is visible. Also, the movie load time takes too long, which
I assume is due to the sound clip being embedded in the movie. Is there a
way to stream the sound so the audio begins immediately? See the referring
URL:

http://www.dwayneepps.com/MHM/index.htm

The button hit state is active for both on and off. I want to disable the
appropriate hit state according to which button is visible. So, if the
playB (audio playing) button is visible then I don't want the button to be
active over the "On" area but only on the "Off". Each button hit state is
set that way, but both are active when the movie plays. I have tried
disabling the hit states with the following code but it hasn't worked.
stopB.enabled=false

Here is the code that I'm using to play the audio and display the buttons:
bgSound = new Sound(this);
bgSound.attachSound("sound1");
bgSound.start(0, 99);
stopB._visible=false;
stopB.onRelease = function() {
bgSound.start(0, 99);
playB._visible=true;
stopB._visible=false;
};
playB.onRelease = function() {
bgSound.stop();
playB._visible=false;
stopB._visible=true;
};
stop();

Thanks in advance for any help.
-D-

Mykoo
hey News-

first i'm thinking:



instead of making a function for each button, make a more anonymous function that tells ANY button to become invisible when it's pressed.

example (in it's simplest form):

hideMe = function() {
this.onRelease = function(){
this._visible = false;
}
}
//
//
playB.onRelease = hideMe;
playA.onRelease=hideMe;








-
-
-
-
if it weren't for my horse i never would've gotten into college

urami_
in flash MX you can give button instance name
and use
myButton.enabled=0; to deactivate it and enabeld=1 to set it back ON




Regards

urami_*



<lsym>

There's no place like 127.0.0.1

</lsym>

Dwayne Epps
Hi Urami,
Thanks for the help. I was trying that earlier and couldn't get it to
work, but I figured out the problem was how I had the hit state set for the
buttons. I finally have the button working the way that I want. If I can
ask one more question, the load time for the sound takes too long. Is there
a way I can get the audio to load quickly...streaming? I figured the load
time is taking longer because the MP3 clip is embedded. Is there some way
to fix this? For example, I have created a page where a user can listen to
audio clips and I used M3U files, which downloads immediately and starts
playing the actual MP3 file, but that is with HTML and not Flash. Is there
something similar I can do within Flash?

Here is the code for the button toggle to play the audio clip in Flash:
bgSound = new Sound(this);
bgSound.attachSound("sound1");
bgSound.start(0, 99);
stopB._visible=false;
stopB.onRelease = function() {
bgSound.start(0, 99);
playB._visible=true;
stopB._visible=false;
};
playB.onRelease = function() {
bgSound.stop();
playB._visible=false;
stopB._visible=true;
};
stop();

Referring URL:
http://www.dwayneepps.com/MHM/index.htm

I appreciate your help! Thanks again.
-D-


"urami_" <[Email Removed]> wrote in message
news:[Email Removed]...
QUOTE
in flash MX you can give button instance name
and use
myButton.enabled=0; to deactivate it and enabeld=1 to set it back ON




Regards

urami_*



<lsym

There's no place like 127.0.0.1

</lsym


urami_
QUOTE
Thanks for the help.  I was trying that earlier and couldn't get it to
work, but I figured out the problem was how I had the hit state set for the
buttons.  I finally have the button working the way that I want.  If I can
ask one more question, the load time for the sound takes too long.  Is there
a way I can get the audio to load quickly...streaming?  I figured the load
time is taking longer because the MP3 clip is embedded.  Is there some way
to fix this?  For example, I have created a page where a user can listen to
audio clips and I used M3U files, which downloads immediately and starts
playing the actual MP3 file, but that is with HTML and not Flash.  Is there
something similar I can do within Flash?


Loading the sound separately would definitely be beneficial .
FLash MX can directly load mp3 files , it can either stream it or run as event sound.
the key here will be your compression actually. If the sound is properly compress it can
be extremely small and very fast for download . While using streaming it would run immediately.

for instance in case of Voice there is different type compression because audio is not alike the complex layered music.
There is many ways to efficiently compress lengthy voice file to really small
file with unusually clear quality ...
Save it as ADPCM (adaptive pulse code modulation) or Mp3 9kbps as your second choice.

For each sound I would apply individual compression setting to optimize the size and quality .
Than would try to stream it using the load sound action .


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.