Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 923575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:12:53+00:00 2026-05-15T19:12:53+00:00

I have devised the following method for catching errors throughout my AS3 applications: In

  • 0

I have devised the following method for catching errors throughout my AS3 applications:

In the Document class, define the following methods:

//This is the handler for listening for errors
protected function catchError(event:ErrorEvent):void 
{ 
  displayError('Error caught: ' + event.text);
}

//Creates a MovieClip with a TextField as the child.
//Adds the MC to the stage
protected function displayError(msg:String):void
{
  var errorMC:MovieClip = new MovieClip();
  errorMC.graphics.beginFill(0xffffff);
  errorMC.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
  errorMC.graphics.endFill();

  var errorTxt:TextField = new TextField();
  errorTxt.multiline = true;
  errorTxt.width = stage.width;
  errorTxt.height = stage.height;
  errorTxt.selectable = true;
  addChild(errorMC);
  addChild(errorTxt);

  errorTxt.text = 'Error(s) Caught: \n' + msg;
}

To deal with classes that are used within the Document class I add the following so that I can register the previously mentioned functions:

protected var errorCatcher:Function;
protected var displayError:Function;

public function setErrorDisplayer(f:Function):void
{
  displayError = f;
}

public function setErrorCatcher(f:Function):void
{
  errorCatcher = f;
}

Now, I can display errors in the SWF at runtime, when testing the application in the browser.

For example:
(I didn’t test the following it’s just an example)

//Document class
package com
{
  import flash.display.MovieClip;
  import flash.event.ErrorEvent;
  import flash.text.TextField;
  import com.SomeClass;

  public class Document extends MovieClip
  {
    protected var someClass:SomeClass = new SomeClass();

    public function Document():void 
    {
      someClass.setErrorCatcher(catchError);
      someClass.setErrorDisplayer(displayError);
    }

    protected function catchError(event:ErrorEvent):void 
    { 
      displayError('Error caught: ' + event.text);
    }

    protected function displayError(msg:String):void
    {
      var errorMC:MovieClip = new MovieClip();
      errorMC.graphics.beginFill(0xffffff);
      errorMC.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
      errorMC.graphics.endFill();

      var errorTxt:TextField = new TextField();
      errorTxt.multiline = true;
      errorTxt.width = stage.width;
      errorTxt.height = stage.height;
      errorTxt.selectable = true;
      addChild(errorMC);
      addChild(errorTxt);

      errorTxt.text = 'Error(s) Caught: \n' + msg;
    }
  }
}

Is this overkill or am I missing a “best practice” here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:12:53+00:00Added an answer on May 15, 2026 at 7:12 pm

    You can just use FireBug to Debug and output from a SWF in the browser. Just Google for “firebug as3”, and you will see a ton of people are doing this.

    You can also use something like De MonsterDebugger. It has a lot of great features. For an overview, check out Lee Brimlows De MonsterDebugger video from GoToAndLearn.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.