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

  • SEARCH
  • Home
  • 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

Ask A Question

Stats

  • Questions 494k
  • Answers 494k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Database: For deploying your SQL Server DB, check out the… May 16, 2026 at 10:55 am
  • Editorial Team
    Editorial Team added an answer This uses only CSS. The classes are not used and… May 16, 2026 at 10:55 am
  • Editorial Team
    Editorial Team added an answer See the accepted answer to a very similar question. When… May 16, 2026 at 10:55 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have this $number = 0.5 if (is_float($number)) { echo 'float'; } else {
So I started reading this book: http://www.amazon.com/Cocoa-Design-Patterns-Erik-Buck/dp/0321535022 On chapter 2 it explains about the
From my experience I have learn that using an surrogate INT data type column
I have a User and an Admin role in my project. I created my
I'm using Devise as authenticating solution in Rails and I have a cached fragment
Have noticed issue while testing iphone app that if one quickly opens/dismisses a modal
Have I correctly added an element to a hashTable? Flows flows = new Flows(sIP,dIP);
i have two richtextboxes one below the other in my application.when the user start
I have an Exec SQL Task that runs a simple select statement but is
I have a question regarding memory deallocation and exceptions. when I use delete to

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.