spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column83


Embedding Sound with Flash, Part III: Streams

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Suppressing JavaScript Error Messages

Suppressing error messages is a controversial issue in all programming languages. That's a classical programmer dilemma. Should a program scream when a bug is found, or should the bug go unnoticed? Since this is almost a "religious" issue, it is left for your own decision. What is not questionable is the need for error messages during the early development stages of the program. In this phase, you probably need the error messages for debugging your new script.

The FlashSound JavaScript API lets you choose whether to suppress error message or not, with the muteErrorMsg property of the FlashSound object. Notice the double negative here. In order to suppress error message, you need to set this property to false. Set it to true during the debugging phase. The default setting is true, i.e. error messages are suppressed by default.

The following JavaScript code includes an error, because the variable a is not defined:

<SCRIPT LANGUAGE="JavaScript">
  FlashSound.muteErrorMsg = a;  
</SCRIPT>

We can choose to get or suppress an error message for this JavaScript error. The following script will suppress the error:

<SCRIPT LANGUAGE="JavaScript">
  FlashSound.muteErrorMsg = true;
  FlashSound.muteErrorMsg = a;  
</SCRIPT>

And the following script will reveal the error:

<SCRIPT LANGUAGE="JavaScript">
  FlashSound.muteErrorMsg = false;
  FlashSound.muteErrorMsg = a;  
</SCRIPT>

Click the following two links to see a demo for each of these two file:

Reveal Error Messages  Suppress Error Messages

Here is the source code for the file that reveals the error:

<HTML>
<HEAD>
<SCRIPT SRC="flashsound.js"></SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
  FlashSound.muteErrorMsg = false;
  FlashSound.muteErrorMsg = a;  
</SCRIPT>
</BODY>
</HTML>

And here is the source code for the file that suppress the error:

<HTML>
<HEAD>
<SCRIPT SRC="flashsound.js"></SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
  FlashSound.muteErrorMsg = true;
  FlashSound.muteErrorMsg = a;  
</SCRIPT>
</BODY>
</HTML>

Next: A Final Word

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: May 7, 2001
Revised: May 7, 2001

URL: http://www.webreference.com/js/column83/12.html