Various ramblings-on, mostly about Red5

23 Jan 09 The dreaded 2044 error

For those of us who have encountered this error, we can understand each others pain. I searched all around and never found a solution to my particular situation. I found Renaun’s post helpful but it didn’t resolve my issue, as well as these other posts:

So here is how this all came about – I had built an AIR application using FlexBuilder, which created a LocalConnection to listen for events from a Native (C++) Windows application. The error would occur when the native application was executed prior to starting the AIR application. I tried everything to catch the error and prevent the dialog from appearing; in FlexBuilder this was especially annoying because the dialog would popup behind the IDE before the application window was visible and prevent it from becomming visble until the dialog was closed. I tried creating the LocalConnection on the following events of WindowedApplication:





None of which worked, this is also the order in which these event fire by-the-way. So as a last resort, I tried the “preloader” option and BINGO! The preloader runs just before the application so it is able to catch the events comming from the native application, since it would appear that Flash starts listening too early (in my case). Now on to the code…

Add the preloader attribute to the top of your application mxml


package org.gregoire {

	import org.gregoire.event.*;

	import mx.preloaders.DownloadProgressBar;	

	public class Preloader extends DownloadProgressBar {   

		private var localCon:CustomLocalConnection;
		private var srcWidth:int;
		private var srcHeight:int;		

		public function Preloader() {
			try {
				//create local connection to provide capture source dimensions
				localCon = new CustomLocalConnection("_myBrowser");
				//setup event listeners for changes on the capture source
				localCon.addEventListener(SourceEvent.CHANGED, sourceEventHandler);
			} catch(e:Error) {
				trace("Error with (preloader) LC: " + e);

		private function sourceEventHandler(event:SourceEvent):void {
			trace("Preloader Source change event: " + event);
			srcWidth = event.getWidth();
			srcHeight = event.getHeight();

		public function hasDimensions():Boolean {
			return (srcWidth > 0 && srcHeight > 0);

		public function getSourceWidth():int {
			return srcWidth;

		public function getSourceHeight():int {
			return srcHeight;

		public function unregister():void {
			localCon.removeEventListener(SourceEvent.CHANGED, sourceEventHandler);
			localCon = null;



package {

    import org.gregoire.event.SourceEvent;

    public class CustomLocalConnection extends LocalConnection {

        public function CustomLocalConnection(connectionName:String) {
            try {
                addEventListener(StatusEvent.STATUS, onStatus);
                addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);

				client = this;

            } catch (error:ArgumentError) {
                // server already created/connected

        public function onSourceSelect(sourceName:String):void {
            trace("onSourceSelect called: " + sourceName);
            var evt:SourceEvent = new SourceEvent();

        public function onSize(dimension:String):void {
            trace("onSize called: " + dimension);
            //split the dimension string into width and height
            var arr:Array = dimension.split("|", 2);
            if (arr.length >= 2) {
	            var evt:SourceEvent = new SourceEvent();
            } else {
            	trace("Dimension could not be properly parsed");


		private function onStatus(event:StatusEvent):void {
			trace("LC event: " + event);
			switch (event.level) {
               case "status":
                   trace("LocalConnection.send() succeeded");
               case "error":
                   trace("LocalConnection.send() failed");

		private function onSecurityError(e:Error):void {
			trace("LC error: " + e);


package org.gregoire.event {


	public class SourceEvent extends Event {

		public static const CHANGED:String = "sourceChanged";

		private var sourceName:String;
		private var width:int;
		private var height:int;

		public function SourceEvent() {

        public function getSourceName():String {
        	return sourceName;

        public function setSourceName(sourceName:String):void {
        	this.sourceName = sourceName;

        public function getWidth():int {
        	return width;

        public function setWidth(width:int):void {
        	this.width = width;

        public function getHeight():int {
        	return height;

        public function setHeight(height:int):void {
        	this.height = height;

        // Override the inherited clone() method.
        override public function clone():Event {
            return new SourceEvent();

		override public function toString():String{
			return "[SourceEvent] sourceName="+sourceName+",width="+width+",height="+height;


I cannot release more than that at this time, but I will try to provide more later if possible. This information should be enough to get you past the 2044 error.

Tags: , , , ,

Reader's Comments

  1. |

    I understand you can’t share much more, but you’re able to communicate directly through a LocalConnection to a C++ app? That’s pretty sweet :) Is there anything at all you can share more, ie the library you’re using to create a LocalConnection in C++?

  2. |

    Sometimes a #2044 Error can occur from an unhandled IOErrorEvent. Most people listen only for an Error or SecurityError event. My experience has been that if you listen for the IOErrorEvent.IO_ERROR event for /any/ data communications, your application will get far less uncaught exception errors. Details here:

  3. |

    @Joeflash, I tried your approach in addition to the others (sorry i didn’t link in the post); it will not work in my case.

  4. |

    @TK, the native application has a swf embedded so that it may communicate with the LocalConnection. There is however a native way out there to do the LC (which I have not tested), check this out

  5. |

    Paul, thanks, I’ll look into that. Seems really intriguing.

  6. |

    i also face the same problem..
    can i ask something..
    where is actually to put preloader=”org.gregoire.Preloader”

    is it at this? –>

    and after add this, i got this strange error..
    1172: Definition org.gregoire:Preloader could not be found.
    its actually not display as error at the interface but i cant execute this because it says it has error although my interface is clean enough.
    i know type of this error just when i open window>problem and i can see it from there.

    hope u can really help me..

Leave a Comment

Fatal error: Call to undefined function akismet_counter() in C:\xampp\htdocs\paulgregoireblog\wp-content\themes\googlechrome\footer.php on line 9