royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject [royale-asjs] 02/02: Prevent multiple listeners and remove used listeners
Date Sat, 07 Oct 2017 19:13:49 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 8281cd01a84cd1c07cb5956d30cc90abfa2cf1b5
Author: Harbs <harbs@in-tools.com>
AuthorDate: Sat Oct 7 22:13:40 2017 +0300

    Prevent multiple listeners and remove used listeners
---
 .../src/main/flex/org/apache/flex/core/ImageViewBase.as | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as
index bfe7cf4..7059f0e 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as
@@ -142,15 +142,20 @@ package org.apache.flex.core
 		{
 			return (_strand as IImage).imageElement;
 		}
-			
+		
+        COMPILE::JS
+        private var _sizeHandlerSet:Boolean;
         COMPILE::JS
 		public function setupLoader():void
         {
             var host:IUIBase = _strand as IUIBase;
-            imageElement.addEventListener('load',
-                loadHandler, false);
-            host.addEventListener('sizeChanged',
-                sizeChangedHandler);
+            imageElement.addEventListener('load', loadHandler);
+            //only do this once. We don't want multiple event listeners
+            if(!_sizeHandlerSet)
+            {
+                host.addEventListener('sizeChanged', sizeChangedHandler);
+                _sizeHandlerSet = true;
+            }
         }
 		
 		/**
@@ -159,6 +164,7 @@ package org.apache.flex.core
         COMPILE::SWF
 		private function onComplete(event:Object):void
 		{
+            loader.contentLoaderInfo.removeEventListener("complete",onComplete);
             var host:ILayoutChild = ILayoutChild(_strand);
 			var hostSprite:Sprite = (host as IRenderedObject).$displayObject as Sprite;
 			
@@ -208,6 +214,7 @@ package org.apache.flex.core
         COMPILE::JS
         protected function loadHandler(event:Object):void
         {
+            imageElement.removeEventListener('load', loadHandler);
             var host:IUIBase = _strand as IUIBase;
 			host.dispatchEvent(new Event("layoutNeeded"));
         }

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

Mime
View raw message