Index: /CKEditor/branches/features/adobeair/_source/core/dom/node.js
===================================================================
--- /CKEditor/branches/features/adobeair/_source/core/dom/node.js	(revision 4310)
+++ /CKEditor/branches/features/adobeair/_source/core/dom/node.js	(revision 4311)
@@ -230,12 +230,5 @@
 		getDocument : function()
 		{
-			var document = new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument );
-
-			return (
-			/** @ignore */
-			this.getDocument = function()
-				{
-					return document;
-				})();
+			return new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument );
 		},
 
Index: /CKEditor/branches/features/adobeair/_source/plugins/panel/plugin.js
===================================================================
--- /CKEditor/branches/features/adobeair/_source/plugins/panel/plugin.js	(revision 4310)
+++ /CKEditor/branches/features/adobeair/_source/plugins/panel/plugin.js	(revision 4311)
@@ -97,7 +97,17 @@
 						'<iframe id="', id, '_frame"' +
 							' frameborder="0"' +
-							' src="javascript:void(' );
-
-			output.push(
+							' src="' );
+
+			// The iframe must source from a 'application sandbox' file,
+			// otherwise the dynamically linked stylesheets and scripts
+			// won't work.
+			if( CKEDITOR.env.air )
+			{
+				output.push( CKEDITOR.basePath + 'air_sandbox_frame.html' );
+			}
+			else
+			{
+				output.push( 'javascript:void(' );
+				output.push(
 							// Support for custom document.domain in IE.
 							CKEDITOR.env.isCustomDomain() ?
@@ -109,7 +119,9 @@
 							:
 								'0' );
+				output.push( ')' );
+			}
 
 			output.push(
-						')"></iframe>' );
+						'"></iframe>' );
 		}
 
@@ -142,4 +154,39 @@
 				var onLoad = CKEDITOR.tools.addFunction( CKEDITOR.tools.bind( function( ev )
 					{
+						var doc = iframe.getFrameDocument(),
+							body = doc.getBody();
+
+						if ( CKEDITOR.env.air )
+							doc.write( data );
+
+						if ( !holder )
+							holder = body;
+						else
+						{
+							this._.holder.moveChildren( body );
+							this._.holder = body;
+						}
+
+						var win = doc.getWindow();
+
+						// Register the CKEDITOR global.
+						win.$.CKEDITOR = CKEDITOR;
+
+						doc.on( 'keydown', function( evt )
+							{
+								var keystroke = evt.data.getKeystroke();
+
+								// Delegate key processing to block.
+								if ( this._.onKeyDown && this._.onKeyDown( keystroke ) === false )
+								{
+									evt.data.preventDefault();
+									return;
+								}
+
+								if ( keystroke == 27 )		// ESC
+									this.onEscape && this.onEscape();
+							},
+							this );
+
 						this.isLoaded = true;
 						if ( this.onLoad )
@@ -147,5 +194,5 @@
 					}, this ) );
 
-				doc.write(
+				var data =
 					'<!DOCTYPE html>' +
 					'<html dir="' + dir + '" class="' + className + '_container" lang="' + langCode + '">' +
@@ -153,6 +200,5 @@
 							'<style>.' + className + '_container{visibility:hidden}</style>' +
 						'</head>' +
-						'<body class="cke_' + dir + ' cke_panel_frame ' + CKEDITOR.env.cssClass + '" style="margin:0;padding:0"' +
-						' onload="( window.CKEDITOR || window.parent.CKEDITOR ).tools.callFunction(' + onLoad + ');">' +
+						'<body class="cke_' + dir + ' cke_panel_frame ' + CKEDITOR.env.cssClass + '" style="margin:0;padding:0" >' +
 						'</body>' +
 						// It looks strange, but for FF2, the styles must go
@@ -160,31 +206,15 @@
 						// available. (#3031)
 						'<link type="text/css" rel=stylesheet href="' + this.css.join( '"><link type="text/css" rel="stylesheet" href="' ) + '">' +
-					'<\/html>' );
-
-				var win = doc.getWindow();
-
-				// Register the CKEDITOR global.
-				win.$.CKEDITOR = CKEDITOR;
-
-				doc.on( 'keydown', function( evt )
-					{
-						var keystroke = evt.data.getKeystroke();
-
-						// Delegate key processing to block.
-						if ( this._.onKeyDown && this._.onKeyDown( keystroke ) === false )
-						{
-							evt.data.preventDefault();
-							return;
-						}
-
-						if ( keystroke == 27 )		// ESC
-							this.onEscape && this.onEscape();
-					},
-					this );
-
-				holder = doc.getBody();
-
-				if( CKEDITOR.env.air )
+					'<\/html>';
+
+				iframe.on( 'load', function( evt )
+				{
 					CKEDITOR.tools.callFunction( onLoad );
+				} );
+				if( !CKEDITOR.env.air )
+					doc.write( data );
+
+				if( !holder )
+					holder = new CKEDITOR.dom.element( 'body', doc );
 			}
 			else
Index: /CKEditor/branches/features/adobeair/_source/plugins/richcombo/plugin.js
===================================================================
--- /CKEditor/branches/features/adobeair/_source/plugins/richcombo/plugin.js	(revision 4310)
+++ /CKEditor/branches/features/adobeair/_source/plugins/richcombo/plugin.js	(revision 4311)
@@ -275,5 +275,10 @@
 
 			if ( this.init )
-				this.init();
+			{
+				var innerPanel = panel._.panel;
+				innerPanel.isLoaded ?
+				 this.init()
+				 : innerPanel.onLoad = CKEDITOR.tools.bind( this.init, this );
+			}
 		},
 
Index: /CKEditor/branches/features/adobeair/_source/plugins/selection/plugin.js
===================================================================
--- /CKEditor/branches/features/adobeair/_source/plugins/selection/plugin.js	(revision 4310)
+++ /CKEditor/branches/features/adobeair/_source/plugins/selection/plugin.js	(revision 4311)
@@ -679,5 +679,5 @@
 						node = sel.anchorNode;
 
-						if ( node.nodeType != 1 )
+						if ( node && node.nodeType != 1 )
 							node = node.parentNode;
 					}
Index: /CKEditor/branches/features/adobeair/air_sandbox_frame.html
===================================================================
--- /CKEditor/branches/features/adobeair/air_sandbox_frame.html	(revision 4310)
+++ /CKEditor/branches/features/adobeair/air_sandbox_frame.html	(revision 4311)
@@ -7,4 +7,9 @@
 <head>
 	<title></title>
+	<script> window.onload = function()
+	{
+		var onload = parent.air_sandbox_frame_load;
+		if( onload) onload();	
+	}</script>
 </head>
 <body ></body>
