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


The following commit(s) were added to refs/heads/develop by this push:
     new c4bf49b  Added replaceBead utility function
c4bf49b is described below

commit c4bf49b967e150c616ac2773b0d919dcdc190734
Author: Harbs <[email protected]>
AuthorDate: Mon Jan 28 12:15:59 2019 +0200

    Added replaceBead utility function
---
 .../projects/Core/src/main/royale/CoreClasses.as   |  2 ++
 .../royale/org/apache/royale/utils/replaceBead.as  | 34 ++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/frameworks/projects/Core/src/main/royale/CoreClasses.as 
b/frameworks/projects/Core/src/main/royale/CoreClasses.as
index 9802c43..a06c1fc 100644
--- a/frameworks/projects/Core/src/main/royale/CoreClasses.as
+++ b/frameworks/projects/Core/src/main/royale/CoreClasses.as
@@ -294,6 +294,8 @@ import org.apache.royale.events.ItemRemovedEvent; 
ItemRemovedEvent;
        import org.apache.royale.utils.date.addYears; addYears;
 
        import org.apache.royale.utils.css.addDynamicSelector; 
addDynamicSelector;
+       
+       import org.apache.royale.utils.replaceBead; replaceBead;
 
     import org.apache.royale.core.TextLineMetrics; TextLineMetrics;
     import org.apache.royale.utils.ClassSelectorList; ClassSelectorList;
diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/replaceBead.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/replaceBead.as
new file mode 100644
index 0000000..40ec045
--- /dev/null
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/replaceBead.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.utils
+{
+  import org.apache.royale.core.IStrand;
+  import org.apache.royale.core.IBead;
+
+  public function replaceBead(strand:IStrand, 
bead:IBead,classOrInterface:Class):IBead
+  {
+    var oldBead:IBead = strand.getBeadByType(classOrInterface);
+    if(oldBead)
+    {
+      strand.removeBead(oldBead);
+    }
+    strand.addBead(bead);
+    return oldBead;
+  }
+}
\ No newline at end of file

Reply via email to