You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by pi...@apache.org on 2018/01/14 11:55:54 UTC

[royale-asjs] branch develop updated: Clean up Alert component.

This is an automated email from the ASF dual-hosted git repository.

piotrz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new f0c2582  Clean up Alert component.
f0c2582 is described below

commit f0c25820de766dc3d66ec0678d9dd71fd1db931a
Author: Piotr Zarzycki <pi...@gmail.com>
AuthorDate: Sun Jan 14 12:55:38 2018 +0100

    Clean up Alert component.
    
    - Fix layout on JS sight.
    - Move creation of all parts to the AlertView
    - Introduce CloseEvent
---
 .../projects/Basic/src/main/resources/defaults.css |   7 +-
 .../projects/Basic/src/main/royale/BasicClasses.as |   4 +-
 .../main/royale/org/apache/royale/html/Alert.as    | 169 +++----------
 .../org/apache/royale/html/beads/AlertView.as      | 278 ++++++++++++++-------
 .../html/beads/controllers/AlertController.as      |  29 ++-
 .../projects/Core/src/main/royale/CoreClasses.as   |   1 +
 .../org/apache/royale/core/IMeasurementBead.as     |   2 +-
 .../royale/org/apache/royale/events/CloseEvent.as  |  56 +++++
 8 files changed, 298 insertions(+), 248 deletions(-)

diff --git a/frameworks/projects/Basic/src/main/resources/defaults.css b/frameworks/projects/Basic/src/main/resources/defaults.css
index 85b6806..7c9f4d5 100644
--- a/frameworks/projects/Basic/src/main/resources/defaults.css
+++ b/frameworks/projects/Basic/src/main/resources/defaults.css
@@ -45,8 +45,11 @@
 
 Alert
 {
+	IBeadLayout: ClassReference("org.apache.royale.html.beads.layouts.VerticalFlexLayout");
+	IBeadView:  ClassReference("org.apache.royale.html.beads.AlertView");
+	IBeadController: ClassReference("org.apache.royale.html.beads.controllers.AlertController");
 	IBeadModel: ClassReference("org.apache.royale.html.beads.models.AlertModel");
-	
+
 	background-color: #FFFFFF;
 	border-style: solid;
 	border-color: #000000;
@@ -644,8 +647,6 @@ global
 	
 	Alert
 	{
-		IBeadView:  ClassReference("org.apache.royale.html.beads.AlertView");
-		IBeadController: ClassReference("org.apache.royale.html.beads.controllers.AlertController");
 		IBackgroundBead: ClassReference("org.apache.royale.html.beads.SolidBackgroundBead");
 		IBorderBead: ClassReference("org.apache.royale.html.beads.SingleLineBorderBead");
 	}
diff --git a/frameworks/projects/Basic/src/main/royale/BasicClasses.as b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
index 6c7213c..c462a1e 100644
--- a/frameworks/projects/Basic/src/main/royale/BasicClasses.as
+++ b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
@@ -39,7 +39,8 @@ internal class BasicClasses
 	import org.apache.royale.html.accessories.TextPromptBead; TextPromptBead;
 	import org.apache.royale.html.beads.AbsolutePositioningViewBeadBase; AbsolutePositioningViewBeadBase;
     import org.apache.royale.html.beads.AlertView; AlertView;
-    import org.apache.royale.html.beads.models.AlertModel; AlertModel;
+    import org.apache.royale.html.beads.controllers.AlertController; AlertController;
+	
 	COMPILE::SWF
 	{
 		import org.apache.royale.html.beads.BackgroundImageBead; BackgroundImageBead;
@@ -129,7 +130,6 @@ internal class BasicClasses
 	import org.apache.royale.html.beads.models.ViewportModel; ViewportModel;
 	COMPILE::SWF
 	{
-	    import org.apache.royale.html.beads.controllers.AlertController; AlertController;
     	import org.apache.royale.html.beads.controllers.DropDownListController; DropDownListController;
 		import org.apache.royale.html.beads.controllers.EditableTextKeyboardController; EditableTextKeyboardController;
 	}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/Alert.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/Alert.as
index 90249d2..70764c5 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/Alert.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/Alert.as
@@ -20,15 +20,8 @@ package org.apache.royale.html
 {
 	import org.apache.royale.core.IAlertModel;
 	import org.apache.royale.core.IPopUp;
-	import org.apache.royale.core.UIBase;
 
-    COMPILE::JS
-    {
-        import goog.events;
-        import org.apache.royale.core.WrappedHTMLElement;
-        import org.apache.royale.events.Event;
-    }
-	
+    [Event(name="close", type="org.apache.royale.events.CloseEvent")]
 	/**
 	 *  The Alert class is a component that displays a message and one or more buttons
 	 *  in a view that pops up over all other controls and views. The Alert component
@@ -47,7 +40,7 @@ package org.apache.royale.html
 	 *  @playerversion AIR 2.6
 	 *  @productversion Royale 0.0
 	 */
-	public class Alert extends UIBase implements IPopUp
+	public class Alert extends Group implements IPopUp
 	{
 		/**
 		 *  The bitmask button flag to show the YES button.
@@ -104,83 +97,27 @@ package org.apache.royale.html
 			className = "Alert";
 		}
 
-        COMPILE::JS
-        private var titleBar:TitleBar;
-        
-        COMPILE::JS
-        private var label:Label;
-        
-        COMPILE::JS
-        private var buttonArea:Container;
-        
-        /**
-         * @override
-         */
-        COMPILE::JS
-        override protected function createElement():WrappedHTMLElement
-        {
-            super.createElement();
-            
-            element.className = 'Alert';
-            
-            // add in a title bar
-            titleBar = new TitleBar();
-            addElement(titleBar);
-            titleBar.element.id = 'titleBar';
-            titleBar.percentWidth = 100;
-            titleBar.height = 24;
-            titleBar.element.style.top = "0px";
-            titleBar.element.style.right = "0px";
-            titleBar.element.style.left = "0px";
-            titleBar.element.style.marginBottom = "6px";
-
-            
-            label = new Label();
-            addElement(label);
-            label.element.style.display = "block";
-            label.element.style.padding = "6px";
-            label.element.style.left = "0px";
-            label.element.style.right = "0px";
-            label.element.style.whiteSpace = "normal";
-
-            label.element.id = 'message';
-            
-            // add a place for the buttons
-            buttonArea = new Container();
-            buttonArea.percentWidth = 100;
-            buttonArea.height = 30;
-            addElement(buttonArea);
-            buttonArea.element.style.marginTop = "6px";
-            buttonArea.element.style.marginBottom = "6px";
-            buttonArea.element.style.padding = "2px";
-            buttonArea.element.style.left = "0px";
-            buttonArea.element.style.right = "0px";
-            buttonArea.element.id = 'buttonArea';
-            
-            return element;
-        };
-		
-		// note: only passing parent to this function as I don't see a way to identify
-		// the 'application' or top level view without supplying a place to start to
-		// look for it.
-		/**
-		 *  This static method is a convenience function to quickly create and display an Alert. The
-		 *  text and parent paramters are required, the others will default.
-		 * 
-		 *  @param String text The message content of the Alert.
-		 *  @param Object parent The object that hosts the pop-up.
-		 *  @param String title An optional title for the Alert.
-		 *  @param uint flags Identifies which buttons to display in the alert.
-		 *
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion Royale 0.0
-		 */
-        static public function show( text:String, parent:Object, title:String="", flags:uint=Alert.OK ) : Alert
+         // note: only passing parent to this function as I don't see a way to identify
+         // the 'application' or top level view without supplying a place to start to
+         // look for it.
+         /**
+          *  This static method is a convenience function to quickly create and display an Alert. The
+          *  text and parent paramters are required, the others will default.
+          *
+          *  @param String message The message content of the Alert.
+          *  @param Object parent The object that hosts the pop-up.
+          *  @param String title An optional title for the Alert.
+          *  @param uint flags Identifies which buttons to display in the alert.
+          *
+          *  @langversion 3.0
+          *  @playerversion Flash 10.2
+          *  @playerversion AIR 2.6
+          *  @productversion Royale 0.0
+          */
+        static public function show( message:String, parent:Object, title:String="", flags:uint=Alert.OK ) : Alert
 		{
 			var alert:Alert = new Alert();
-			alert.message = text;
+			alert.message = message;
 			alert.title  = title;
 			alert.flags = flags;
 			
@@ -224,15 +161,12 @@ package org.apache.royale.html
 		{
 			return IAlertModel(model).title;
 		}
+
 		public function set title(value:String):void
 		{
 			IAlertModel(model).title = value;
-            COMPILE::JS {
-                titleBar.title = value;
-            }
-
 		}
-		
+
 		/**
 		 *  The message to display in the Alert body.
 		 *
@@ -248,15 +182,16 @@ package org.apache.royale.html
 		public function set message(value:String):void
 		{
 			IAlertModel(model).message = value;
-            COMPILE::JS {
-                label.text = value;
-            }
-
 		}
-		
+
 		/**
 		 *  The buttons to display on the Alert as bit-mask values.
 		 *
+		 *  Alert.YES
+         *  Alert.NO
+         *  Alert.OK
+         *  Alert.CANCEL
+		 *
 		 *  @langversion 3.0
 		 *  @playerversion Flash 10.2
 		 *  @playerversion AIR 2.6
@@ -269,52 +204,6 @@ package org.apache.royale.html
 		public function set flags(value:uint):void
 		{
 			IAlertModel(model).flags = value;
-            
-            COMPILE::JS
-            {
-                // add buttons based on flags
-                if (flags & Alert.OK) {
-                    var ok:TextButton = new TextButton();
-                    buttonArea.addElement(ok);
-                    ok.text = 'OK';
-                    ok.element.style.margin = "4px";
-                    goog.events.listen(ok.element, 'click', dismissAlert);
-                }
-                if (flags & Alert.CANCEL) {
-                    var cancel:TextButton = new TextButton();
-                    buttonArea.addElement(cancel);
-                    cancel.text = 'Cancel';
-                    cancel.element.style.margin = "4px";
-                    goog.events.listen(cancel.element, 'click', dismissAlert);
-                }
-                if (flags & Alert.YES) {
-                    var yes:TextButton = new TextButton();
-                    buttonArea.addElement(yes);
-                    yes.text = 'YES';
-                    yes.element.style.margin = "4px";
-                    goog.events.listen(yes.element, 'click', dismissAlert);
-                }
-                if (flags & Alert.NO) {
-                    var nob:TextButton = new TextButton();
-                    buttonArea.addElement(nob);
-                    nob.text = 'NO';
-                    nob.element.style.margin = "4px";
-                    goog.events.listen(nob.element, 'click', dismissAlert);
-                }
-                
-            }
 		}
-        
-        /**
-         * @param event The event object.
-         * @royaleignorecoercion HTMLElement
-         */
-        COMPILE::JS
-        private function dismissAlert(event:Event):void
-        {
-            var htmlElement:HTMLElement = element as HTMLElement;
-            htmlElement.parentElement.removeChild(element);
-        };
-	
 	}
 }
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/AlertView.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/AlertView.as
index 2af8969..fab34c5 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/AlertView.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/AlertView.as
@@ -22,22 +22,29 @@ package org.apache.royale.html.beads
 	import org.apache.royale.core.IAlertModel;
 	import org.apache.royale.core.IBead;
     import org.apache.royale.core.IBeadView;
-	import org.apache.royale.core.IMeasurementBead;
     import org.apache.royale.core.IParent;
 	import org.apache.royale.core.IStrand;
 	import org.apache.royale.core.UIBase;
-	import org.apache.royale.core.ValuesManager;
 	import org.apache.royale.events.Event;
     import org.apache.royale.events.MouseEvent;
+    import org.apache.royale.events.CloseEvent;
 	import org.apache.royale.events.IEventDispatcher;
-    import org.apache.royale.geom.Rectangle;
 	import org.apache.royale.html.Alert;
-	import org.apache.royale.html.ControlBar;
+    import org.apache.royale.html.Container;
+    import org.apache.royale.html.ControlBar;
+    import org.apache.royale.html.Group;
     import org.apache.royale.html.Label;
 	import org.apache.royale.html.TextButton;
 	import org.apache.royale.html.TitleBar;
-	import org.apache.royale.utils.CSSContainerUtils;
-	import org.apache.royale.utils.loadBeadFromValuesManager;
+
+	COMPILE::SWF
+	{
+        import org.apache.royale.geom.Rectangle;
+        import org.apache.royale.core.ValuesManager;
+        import org.apache.royale.utils.CSSContainerUtils;
+        import org.apache.royale.utils.loadBeadFromValuesManager;
+        import org.apache.royale.core.IMeasurementBead;
+	}
 	
 	/**
 	 *  The AlertView class creates the visual elements of the org.apache.royale.html.Alert
@@ -49,7 +56,7 @@ package org.apache.royale.html.beads
 	 *  @playerversion AIR 2.6
 	 *  @productversion Royale 0.0
 	 */
-	public class AlertView extends BeadViewBase implements IBeadView
+	public class AlertView extends GroupView
 	{
 		/**
 		 *  constructor.
@@ -63,14 +70,18 @@ package org.apache.royale.html.beads
 		{
 		}
 		
-		private var _titleBar:TitleBar;
-		private var _controlBar:ControlBar;
-		private var _label:Label;
-		private var _okButton:TextButton;
-		private var _cancelButton:TextButton;
-		private var _yesButton:TextButton;
-		private var _noButton:TextButton;
-		
+		protected var titleBar:TitleBar;
+		protected var controlBar:UIBase;
+		protected var label:Label;
+		protected var labelContent:Group;
+
+        protected var okButton:TextButton;
+        protected var cancelButton:TextButton;
+        protected var yesButton:TextButton;
+        protected var noButton:TextButton;
+
+        protected var alertModel:IAlertModel;
+
 		/**
 		 *  @copy org.apache.royale.core.IBead#strand
 		 *  
@@ -83,100 +94,178 @@ package org.apache.royale.html.beads
 		{
 			super.strand = value;
 
-            var backgroundColor:Object = ValuesManager.valuesImpl.getValue(value, "background-color");
-			var backgroundImage:Object = ValuesManager.valuesImpl.getValue(value, "background-image");
-			if (backgroundColor != null || backgroundImage != null)
-			{
-				loadBeadFromValuesManager(IBackgroundBead, "iBackgroundBead", value);
-			}
+			COMPILE::SWF
+            {
+                var backgroundColor:Object = ValuesManager.valuesImpl.getValue(value, "background-color");
+                var backgroundImage:Object = ValuesManager.valuesImpl.getValue(value, "background-image");
+                if (backgroundColor != null || backgroundImage != null)
+                {
+                    loadBeadFromValuesManager(IBackgroundBead, "iBackgroundBead", value);
+                }
+
+                var borderStyle:String;
+                var borderStyles:Object = ValuesManager.valuesImpl.getValue(value, "border");
+                if (borderStyles is Array)
+                {
+                    borderStyle = borderStyles[1];
+                }
+                if (borderStyle == null)
+                {
+                    borderStyle = ValuesManager.valuesImpl.getValue(value, "border-style") as String;
+                }
+                if (borderStyle != null && borderStyle != "none")
+                {
+                    loadBeadFromValuesManager(IBorderBead, "iBorderBead", value);
+                }
+            }
+
+			alertModel = (_strand as UIBase).model as IAlertModel;
+
+			createButtons();
+
+			if (alertModel.title)
+            {
+                titleBar = new TitleBar();
+                titleBar.height = 25;
+                titleBar.title = alertModel.title;
+                IParent(_strand).addElement(titleBar);
+            }
+
+			label = new Label();
+			label.text = alertModel.message;
+			
+			labelContent = new Group();
+			labelContent.percentWidth = 100;
+			labelContent.percentHeight = 100;
+
+			labelContent.addElement(label);
 			
-			var borderStyle:String;
-			var borderStyles:Object = ValuesManager.valuesImpl.getValue(value, "border");
-			if (borderStyles is Array)
+            IParent(_strand).addElement(labelContent);
+
+			COMPILE::JS
 			{
-				borderStyle = borderStyles[1];
+                label.element.style["white-space"] = "unset";
+				labelContent.element.style["minHeight"] = "30px";
+				controlBar.element.style["flex-direction"] = "row";
+				controlBar.element.style["justify-content"] = "flex-end";
+				controlBar.element.style["border"] = "none";
+				controlBar.element.style["background-color"] = "#FFFFFF";
 			}
-			if (borderStyle == null)
+            IParent(_strand).addElement(controlBar);
+
+			COMPILE::SWF
+            {
+                refreshSize();
+            }
+		}
+
+		private function createButtons():void
+		{
+			COMPILE::SWF
 			{
-				borderStyle = ValuesManager.valuesImpl.getValue(value, "border-style") as String;
-			}
-			if (borderStyle != null && borderStyle != "none")
+				controlBar = new Group();
+            }
+
+			COMPILE::JS
 			{
-				loadBeadFromValuesManager(IBorderBead, "iBorderBead", value);
-			}
-			
-			var flags:uint = IAlertModel(UIBase(_strand).model).flags;
-			if( flags & Alert.OK ) {
-				_okButton = new TextButton();
-				_okButton.text = IAlertModel(UIBase(_strand).model).okLabel;
-				_okButton.addEventListener("click",handleOK);
+				controlBar = new ControlBar();
 			}
-			if( flags & Alert.CANCEL ) {
-				_cancelButton = new TextButton();
-				_cancelButton.text = IAlertModel(UIBase(_strand).model).cancelLabel;
-				_cancelButton.addEventListener("click",handleCancel);
-			}
-			if( flags & Alert.YES ) {
-				_yesButton = new TextButton();
-				_yesButton.text = IAlertModel(UIBase(_strand).model).yesLabel;
-				_yesButton.addEventListener("click",handleYes);
-			}
-			if( flags & Alert.NO ) {
-				_noButton = new TextButton();
-				_noButton.text = IAlertModel(UIBase(_strand).model).noLabel;
-				_noButton.addEventListener("click",handleNo);
-			}
-			
-			_titleBar = new TitleBar();
-			_titleBar.title = IAlertModel(UIBase(_strand).model).title;
-			
-			_label = new Label();
-			_label.text = IAlertModel(UIBase(_strand).model).message;
-			
-			_controlBar = new ControlBar();
-			if( _okButton ) _controlBar.addElement(_okButton);
-			if( _cancelButton ) _controlBar.addElement(_cancelButton);
-			if( _yesButton  ) _controlBar.addElement(_yesButton);
-			if( _noButton ) _controlBar.addElement(_noButton);
-			
-		    IParent(_strand).addElement(_titleBar);
-            IParent(_strand).addElement(_controlBar);
-            IParent(_strand).addElement(_label);
-			
-			sizeHandler(null);
+
+            var flags:uint = alertModel.flags;
+            if( flags & Alert.OK )
+            {
+                okButton = new TextButton();
+                okButton.text = alertModel.okLabel;
+                okButton.addEventListener("click",handleOK);
+
+                controlBar.addElement(okButton);
+
+                COMPILE::JS
+                {
+                    okButton.element.style["margin-left"] = "2px";
+                    okButton.element.style["margin-right"] = "2px";
+                }
+            }
+            if( flags & Alert.CANCEL )
+            {
+                cancelButton = new TextButton();
+                cancelButton.text = alertModel.cancelLabel;
+                cancelButton.addEventListener("click",handleCancel);
+
+                controlBar.addElement(cancelButton);
+
+                COMPILE::JS
+                {
+                    cancelButton.element.style["margin-left"] = "2px";
+                    cancelButton.element.style["margin-right"] = "2px";
+                }
+            }
+            if( flags & Alert.YES )
+            {
+                yesButton = new TextButton();
+                yesButton.text = alertModel.yesLabel;
+                yesButton.addEventListener("click",handleYes);
+
+                controlBar.addElement(yesButton);
+
+                COMPILE::JS
+                {
+                    yesButton.element.style["margin-left"] = "2px";
+                    yesButton.element.style["margin-right"] = "2px";
+                }
+            }
+            if( flags & Alert.NO )
+            {
+                noButton = new TextButton();
+                noButton.text = alertModel.noLabel;
+                noButton.addEventListener("click",handleNo);
+
+                controlBar.addElement(noButton);
+
+                COMPILE::JS
+                {
+                    noButton.element.style["margin-left"] = "2px";
+                    noButton.element.style["margin-right"] = "2px";
+                }
+            }
 		}
-		
+
 		/**
 		 * @private
 		 */
-		private function sizeHandler(event:Event):void
+		COMPILE::SWF
+		private function refreshSize():void
 		{
-			var labelMeasure:IMeasurementBead = _label.measurementBead;
-			var titleMeasure:IMeasurementBead = _titleBar.measurementBead;
-			var ctrlMeasure:IMeasurementBead  = _controlBar.measurementBead;
-			var maxWidth:Number = Math.max(titleMeasure.measuredWidth, ctrlMeasure.measuredWidth, labelMeasure.measuredWidth);
-			
+			var labelMeasure:IMeasurementBead = label.measurementBead;
+			var titleMeasure:IMeasurementBead = titleBar.measurementBead;
+			var titleBarWidth:Number = titleBar ? titleBar.measurementBead.measuredWidth : 0;
+
+			var maxWidth:Number = Math.max(titleMeasure.measuredWidth, titleBarWidth, labelMeasure.measuredWidth);
+
 			var metrics:Rectangle = CSSContainerUtils.getBorderAndPaddingMetrics(_strand);
 
-			_titleBar.x = 0;
-			_titleBar.y = 0;
-			_titleBar.width = maxWidth;
-			_titleBar.height = 25;
-			_titleBar.dispatchEvent(new Event("layoutNeeded"));
-			
+            var titleBarHeight:Number = 0;
+			if (titleBar)
+            {
+                titleBarHeight = titleBar.height;
+                titleBar.x = 0;
+                titleBar.y = 0;
+                titleBar.width = maxWidth;
+                titleBar.dispatchEvent(new Event("layoutNeeded"));
+            }
+
 			// content placement here
-			_label.x = metrics.left;
-			_label.y = _titleBar.y + _titleBar.height + metrics.top;
-			_label.width = maxWidth - metrics.left - metrics.right;
+			label.x = metrics.left;
+			label.y = titleBarHeight + metrics.top;
+			label.width = maxWidth - metrics.left - metrics.right;
 			
-			_controlBar.x = 0;
-			_controlBar.y = _titleBar.height + _label.y + _label.height + metrics.bottom;
-			_controlBar.width = maxWidth;
-			_controlBar.height = 25;
-			_controlBar.dispatchEvent(new Event("layoutNeeded"));
+			controlBar.x = 0;
+			controlBar.y = titleBarHeight + label.y + label.height + metrics.bottom;
+			controlBar.width = maxWidth;
+			controlBar.dispatchEvent(new Event("layoutNeeded"));
 			
 			UIBase(_strand).width = maxWidth;
-			UIBase(_strand).height = _titleBar.height + _label.height + _controlBar.height + metrics.top + metrics.bottom;
+			UIBase(_strand).height = titleBarHeight + label.height + controlBar.height + metrics.top + metrics.bottom;
 		}
 		
 		/**
@@ -218,9 +307,8 @@ package org.apache.royale.html.beads
 		 */
 		public function dispatchCloseEvent(buttonFlag:uint):void
 		{
-			// TO DO: buttonFlag should be part of the event
-			var newEvent:Event = new Event("close",true);
-			IEventDispatcher(_strand).dispatchEvent(newEvent);
+			var closeEvent:CloseEvent = new CloseEvent("close", false, false, buttonFlag);
+			IEventDispatcher(_strand).dispatchEvent(closeEvent);
 		}
 	}
 }
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/AlertController.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/AlertController.as
index 9c3bfe6..5a2b818 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/AlertController.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/AlertController.as
@@ -17,12 +17,17 @@
 //
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.html.beads.controllers
-{	
-    import flash.display.DisplayObject;
-    
+{
+    import org.apache.royale.core.UIBase;
+
+    COMPILE::SWF
+    {
+        import flash.display.DisplayObject;
+    }
+
 	import org.apache.royale.core.IBeadController;
 	import org.apache.royale.core.IStrand;
-	import org.apache.royale.events.Event;
+	import org.apache.royale.events.CloseEvent;
 	import org.apache.royale.events.IEventDispatcher;
 
 	/**
@@ -74,15 +79,25 @@ package org.apache.royale.html.beads.controllers
         public function set strand(value:IStrand):void
         {
             _strand = value;
-            IEventDispatcher(value).addEventListener("close",handleAlertClose);
+            IEventDispatcher(value).addEventListener("close", alertCloseHandler);
         }
         
 		/**
 		 * @private
 		 */
-        private function handleAlertClose(event:Event):void
+        private function alertCloseHandler(event:CloseEvent):void
         {
-            DisplayObject(_strand).parent.removeChild(DisplayObject(_strand));
+			COMPILE::SWF
+            {
+                DisplayObject(_strand).parent.removeChild(DisplayObject(_strand));
+            }
+
+			COMPILE::JS
+			{
+				var host:UIBase = strand as UIBase;
+                var htmlElement:HTMLElement = host.element as HTMLElement;
+                htmlElement.parentElement.removeChild(host.element);
+			}
         }
 	}
 }
diff --git a/frameworks/projects/Core/src/main/royale/CoreClasses.as b/frameworks/projects/Core/src/main/royale/CoreClasses.as
index 963d0c0..edd9b69 100644
--- a/frameworks/projects/Core/src/main/royale/CoreClasses.as
+++ b/frameworks/projects/Core/src/main/royale/CoreClasses.as
@@ -121,6 +121,7 @@ internal class CoreClasses
 	import org.apache.royale.core.StyleChangeNotifier; StyleChangeNotifier;
 	import org.apache.royale.events.CustomEvent; CustomEvent;
     import org.apache.royale.events.Event; Event;
+	import org.apache.royale.events.CloseEvent; CloseEvent;
 	import org.apache.royale.events.CollectionEvent; CollectionEvent;
     import org.apache.royale.events.ProgressEvent; ProgressEvent;
 	import org.apache.royale.events.StyleChangeEvent; StyleChangeEvent;
diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IMeasurementBead.as b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IMeasurementBead.as
index 2326753..a32a5e0 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IMeasurementBead.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IMeasurementBead.as
@@ -41,7 +41,7 @@ package org.apache.royale.core
 		function get measuredWidth():Number;
 
         /**
-         *  The measured height                                                                                                                                                                                                                                                                                                                                                                                                                                                                              [...]
+         *  The measured height
          * 
          *  @langversion 3.0
          *  @playerversion Flash 10.2
diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/events/CloseEvent.as b/frameworks/projects/Core/src/main/royale/org/apache/royale/events/CloseEvent.as
new file mode 100644
index 0000000..a591320
--- /dev/null
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/events/CloseEvent.as
@@ -0,0 +1,56 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.events
+{
+	/**
+	 * The CloseEvent class represents event objects specific to popup windows, such as the Alert control.
+	 *
+	 * @langversion 3.0
+	 * @playerversion Flash 10.2
+	 * @playerversion AIR 2.6
+	 * @productversion Royale 0.9
+	 */
+    public class CloseEvent extends Event
+	{
+		public static const CLOSE:String = "close";
+
+		public function CloseEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false,
+                                   detail:uint = 0x000004):void
+		{
+			super(type, bubbles, cancelable);
+
+			this.detail = detail;
+		}
+
+        /**
+         *  Identifies the button in the popped up control that was clicked. This property is for controls with multiple    		 *	buttons. The Alert control sets this property to one of the following constants:
+		 *
+         *  Alert.YES
+         *  Alert.NO
+         *  Alert.OK
+         *  Alert.CANCEL
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.9
+         */
+		public var detail:uint;
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
['"commits@royale.apache.org" <co...@royale.apache.org>'].