             }
         }
 
-		allSystemManagers[this] = this.loaderInfo.url;
-	    root.loaderInfo.removeEventListener(Event.INIT, initHandler);
-
-		if (!SystemManagerGlobals.info)
-			SystemManagerGlobals.info = info();
-		if (!SystemManagerGlobals.parameters)
-			SystemManagerGlobals.parameters = loaderInfo.parameters;
+        allSystemManagers[this] = this.loaderInfo.url;
+        root.loaderInfo.removeEventListener(Event.INIT, initHandler);
+
+        if (!SystemManagerGlobals.info)
+            SystemManagerGlobals.info = info();
+        if (!SystemManagerGlobals.parameters)
+            SystemManagerGlobals.parameters = loaderInfo.parameters;
 
         // This listener is intended to run before any other KeyboardEvent listeners
         // so that it can redispatch a cancelable=true copy of the event. 

    
    private function mouseWheelHandler(e:MouseEvent):void
    {
    	if (!e.cancelable)
    	{
    		e.stopImmediatePropagation();
    		var cancelableEvent:MouseEvent = 
    			new MouseEvent(e.type, e.bubbles, true, e.localX, e.localY, e.relatedObject, 
    						   e.ctrlKey, e.altKey, e.shiftKey, e.buttonDown, e.delta);
    		e.target.dispatchEvent(cancelableEvent);			   
    	}
    }

	private function extraFrameHandler(event:Event = null):void
	{
	    var frameList:Object = info()["frames"];
                        
	    if (frameList && frameList[currentLabel])
        {
	        var c:Class = Class(getDefinitionByName(frameList[currentLabel]));
	        c["frame"](this);
        }

	    deferredNextFrame();
	}
    
    /**
	 *  @private
     *  
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
	 */
	private function nextFrameTimerHandler(event:TimerEvent):void
	{
	    if (currentFrame + 1 <= framesLoaded)
        {
	        nextFrame();
            nextFrameTimer.removeEventListener(TimerEvent.TIMER, nextFrameTimerHandler);
        	// stop the timer
        	nextFrameTimer.reset();
                }
            }
	

    /**
     *  @private

            // no longer need this listener
            try
            {
                if (stage)
                {
                    stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler, false, 0, true);
                }
                else
                {
                    super.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler, false, 0, true);
                }
            }
            catch (error:SecurityError)
            {
                super.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler, false, 0, true);
            }
        }
        
        // These two events will dispatched to applications in sandboxes.
        if (type == FlexEvent.RENDER || type == FlexEvent.ENTER_FRAME)
        {
            if (type == FlexEvent.RENDER)
                type = Event.RENDER;
            else
                type = Event.ENTER_FRAME;
                
            try
            {
                if (stage)
                    stage.addEventListener(type, listener, useCapture, priority, useWeakReference);
                else
                    super.addEventListener(type, listener, useCapture, priority, useWeakReference);
            }
            catch (error:SecurityError)
            {
                super.addEventListener(type, listener, useCapture, priority, useWeakReference);
            }
        
            if (stage && type == Event.RENDER)
                stage.invalidate();

            return;
        }

        // When the first listener registers for 'idle' events,
        // create a Timer that will fire every IDLE_INTERVAL.
        if (type == FlexEvent.IDLE && !idleTimer)
        {
            idleTimer = new Timer(IDLE_INTERVAL);
            idleTimer.addEventListener(TimerEvent.TIMER,
                                       idleTimer_timerHandler);
            idleTimer.start();

            // Make sure we get all activity
            // in case someone calls stopPropagation().
            addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, true);
            addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true);
        }

        super.addEventListener(type, listener, useCapture, priority, useWeakReference);
    }

    /**
     *  @private
     */
    mx_internal final function $removeEventListener(type:String, listener:Function,
                                                 useCapture:Boolean = false):void
    {
        super.removeEventListener(type, listener, useCapture);
    }
    
    /**
     *  @private
     */
    override public function removeEventListener(type:String, listener:Function,
                                                 useCapture:Boolean = false):void
    {
        if (hasEventListener("removeEventListener"))
        {
            var request:DynamicEvent = new DynamicEvent("removeEventListener", false, true);
            request.eventType = type;
            request.listener = listener;
            request.useCapture = useCapture;
            if (!dispatchEvent(request))
                return;
        }

        // These two events will dispatched to applications in sandboxes.
        if (type == FlexEvent.RENDER || type == FlexEvent.ENTER_FRAME)
        {
            if (type == FlexEvent.RENDER)
                type = Event.RENDER;
            else
                type = Event.ENTER_FRAME;
                
            try
            {
                if (stage)
                    stage.removeEventListener(type, listener, useCapture);
            }
            catch (error:SecurityError)
            {
            }
            // Remove both listeners in case the system manager was added
            // or removed from the stage after the listener was added.
            super.removeEventListener(type, listener, useCapture);
        
            return;
        }

        // When the last listener unregisters for 'idle' events,
        // stop and release the Timer.
        if (type == FlexEvent.IDLE)
        {
            super.removeEventListener(type, listener, useCapture);

            if (!hasEventListener(FlexEvent.IDLE) && idleTimer)
            {
                idleTimer.stop();
                idleTimer = null;

                removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
                removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
            }
        }
        else
        {
            super.removeEventListener(type, listener, useCapture);
        }

        if (type == MouseEvent.MOUSE_MOVE || type == MouseEvent.MOUSE_UP || type == MouseEvent.MOUSE_DOWN 
                || type == Event.ACTIVATE || type == Event.DEACTIVATE)
        {
            if (!hasEventListener(type))
            {
                // also listen to stage if allowed
                try
                {
                    if (stage)
                    {
                        stage.removeEventListener(type, stageEventHandler, false);
                    }
                }
                catch (error:SecurityError)
                {
                }
            }
        }

        if (type == SandboxMouseEvent.MOUSE_UP_SOMEWHERE)
        {
