Repository: flex-asjs
Updated Branches:
  refs/heads/develop 5ba5e873b -> 2cc5ca1a7


Add CompoundEffect which allows bead to determine how compound effects are 
handled.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/2cc5ca1a
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/2cc5ca1a
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/2cc5ca1a

Branch: refs/heads/develop
Commit: 2cc5ca1a7efb4fe58826ffc40a5de416e784c99e
Parents: 5ba5e87
Author: yishayw <[email protected]>
Authored: Sun Jan 29 14:45:30 2017 +0200
Committer: yishayw <[email protected]>
Committed: Sun Jan 29 14:45:30 2017 +0200

----------------------------------------------------------------------
 .../org/apache/flex/effects/CompoundEffect.as   | 210 +++++++++++++++++++
 .../org/apache/flex/effects/ICompoundEffect.as  | 117 +++++++++++
 .../flex/effects/beads/ParallelPlayBead.as      |  71 +++++++
 .../src/main/resources/basic-manifest.xml       |   3 +-
 4 files changed, 400 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2cc5ca1a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/CompoundEffect.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/CompoundEffect.as
 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/CompoundEffect.as
new file mode 100644
index 0000000..93a8e14
--- /dev/null
+++ 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/CompoundEffect.as
@@ -0,0 +1,210 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.flex.effects
+{
+       
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.IDocument;
+       import org.apache.flex.core.IUIBase;
+       import org.apache.flex.core.Strand;
+       import org.apache.flex.events.Event;
+       
+       [DefaultProperty("children")]
+       
+       /**
+        *  The ParallelStrand implements ICompoundEffect by dispatching events 
that should be handled by pluggable beads.
+        * 
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion FlexJS 0.0
+        */
+       public class CompoundEffect extends Strand implements IDocument, 
ICompoundEffect
+       {
+               
+               
//--------------------------------------------------------------------------
+               //
+               //  Constructor
+               //
+               
//--------------------------------------------------------------------------
+               
+               /**
+                *  Constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function CompoundEffect()
+               {
+                       super();
+               }
+               
+               
//--------------------------------------------------------------------------
+               //
+               //  Variables
+               //
+               
//--------------------------------------------------------------------------
+               
+               /**
+                *  @private
+                *  The document.
+                */
+               private var document:Object;
+               
+               /**
+                *  @private
+                *  The target.
+                */
+               private var target:IUIBase;
+               
+               private var _children:Array;
+               
+               
+               
+               
//--------------------------------------------------------------------------
+               //
+               //  Properties
+               //
+               
//--------------------------------------------------------------------------
+               
+               /**
+                *  @private
+                */
+               private var _duration:Number = 500;
+               
+               /**
+                *  The children.
+                */
+               public function get children():Array
+               {
+                       return _children;
+               }
+
+               /**
+                * @private
+                */
+               public function set children(value:Array):void
+               {
+                       _children = value;
+               }
+
+               public function set duration(value:Number):void
+               {
+                       _duration = value;
+                       var n:int = children ? children.length : 0;
+                       for (var i:int = 0; i < n; i++)
+                       {
+                               children[i].duration = value;
+                       }
+               }
+
+               public function get duration():Number
+               {
+                       return _duration;
+               }
+
+               
//--------------------------------------------------------------------------
+               //
+               //  Methods
+               //
+               
//--------------------------------------------------------------------------
+               
+               public function setDocument(document:Object, id:String = 
null):void
+               {
+                       this.document = document;
+                       for each (var bead:IBead in beads)
+                       {
+                               addBead(bead);
+                       }
+               }
+               
+               public function addChild(child:IEffect):void
+               {
+                       if (!children)
+                               children = [ child ];
+                       else
+                               children.push(child);    
+               }
+               
+               public function captureEndValues():void
+               {
+                       // TODO Auto Generated method stub
+               }
+               
+               public function captureStartValues():void
+               {
+                       // TODO Auto Generated method stub
+               }
+               
+               public function play():void
+               {
+                       dispatchEvent(new Event('play'));
+               }
+               
+               public function pause():void
+               {
+                       dispatchEvent(new Event('pause'));
+               }
+               
+               public function resume():void
+               {
+                       dispatchEvent(new Event('resume'));
+               }
+               
+               public function reverse():void
+               {
+                       dispatchEvent(new Event('reverse'));
+               }
+               
+               public function stop():void
+               {
+                       dispatchEvent(new Event('stop'));
+               }
+               
+               public function addChildAt(e:IEffect, index:int):void
+               {
+                       _children.insertAt(index, e);
+               }
+               
+               public function getChildAt(index:int):IEffect
+               {
+                       return _children[index];
+               }
+               
+               public function getChildIndex(e:IEffect):int
+               {
+                       return _children.indexOf(e);
+               }
+               
+               public function get numChildren():int
+               {
+                       return _children.length;
+               }
+               
+               public function removeChild(e:IEffect):void
+               {
+                       _children.removeAt(getChildIndex(e));
+               }
+               
+       }
+       
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2cc5ca1a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/ICompoundEffect.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/ICompoundEffect.as
 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/ICompoundEffect.as
new file mode 100644
index 0000000..08fe7e9
--- /dev/null
+++ 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/ICompoundEffect.as
@@ -0,0 +1,117 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.flex.effects
+{
+       
+       /**
+        *  ICompoundEffect aggregates several related effects. Implementors 
will decide on the order in which they're played.
+        * 
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion FlexJS 0.0
+        */
+       public interface ICompoundEffect extends IEffect
+       {
+               
+               
+               
//--------------------------------------------------------------------------
+               //
+               //  Properties
+               //
+               
//--------------------------------------------------------------------------
+               
+               //----------------------------------
+               //  duration
+               //----------------------------------
+               
+               /**
+                *  Add an effect to the parent.
+                * 
+                *  @param c The subeffect to add.
+                * 
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               function addChild(c:IEffect):void;
+               
+               /**
+                *  Add an effect to the parent.
+                * 
+                *  @param c The subeffect to add.
+                * 
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               function addChildAt(c:IEffect, index:int):void;
+               
+               /**
+                *  Gets the index of this subeffect.
+                * 
+                *  @param c The subeffect to add.
+                *  @return The index (zero-based).
+                * 
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               function getChildIndex(c:IEffect):int;
+               
+               /**
+                *  Remove an effect from the parent.
+                * 
+                *  @param c The subeffect to remove.
+                * 
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               function removeChild(c:IEffect):void;
+               
+               /**
+                *  The number of elements in the parent.
+                * 
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               function get numChildren():int;
+               
+               /**
+                *  Get an effect from the parent.
+                * 
+                *  @param c The index of the subeffect.
+                * 
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               function getChildAt(index:int):IEffect;
+       }
+       
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2cc5ca1a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/beads/ParallelPlayBead.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/beads/ParallelPlayBead.as
 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/beads/ParallelPlayBead.as
new file mode 100644
index 0000000..9b2768b
--- /dev/null
+++ 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/beads/ParallelPlayBead.as
@@ -0,0 +1,71 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.flex.effects.beads
+{
+       
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.effects.Effect;
+       import org.apache.flex.effects.ICompoundEffect;
+       import org.apache.flex.effects.IEffect;
+       import org.apache.flex.events.Event;
+       
+       public class ParallelPlayBead implements IBead
+       {
+               private var host:ICompoundEffect;
+               
+               public function ParallelPlayBead()
+               {
+                       super();
+               }
+               
+               public function set strand(value:IStrand):void
+               {
+                       host = value as ICompoundEffect;
+                       host.addEventListener('play', playHandler);
+               }
+               
+               private function playHandler(e:Event):void
+               {
+                       host.dispatchEvent(new Event(Effect.EFFECT_START));
+                       current = 0;
+                       var n:int = host.numChildren;
+                       for (var i:int = 0; i < n; i++)          
+                               playChildEffect(i);
+               }
+               
+               
+               private var current:int;
+               
+               private function playChildEffect(index:int):void
+               {
+                       var child:IEffect = host.getChildAt(index);
+                       child.addEventListener(Effect.EFFECT_END, 
effectEndHandler);
+                       child.play();   
+               }
+               
+               private function effectEndHandler(event:Event):void
+               {
+                       current++;
+                       if (current >= host.numChildren)
+                               host.dispatchEvent(new 
Event(Effect.EFFECT_END));
+               }
+               
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2cc5ca1a/frameworks/projects/Effects/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Effects/src/main/resources/basic-manifest.xml 
b/frameworks/projects/Effects/src/main/resources/basic-manifest.xml
index 3b060a2..7d2d61b 100644
--- a/frameworks/projects/Effects/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Effects/src/main/resources/basic-manifest.xml
@@ -20,13 +20,14 @@
 
 
 <componentPackage>
-
+    <component id="ParallelPlayBead" 
class="org.apache.flex.effects.beads.ParallelPlayBead"/>
     <component id="Fade" class="org.apache.flex.effects.Fade"/>
     <component id="Move" class="org.apache.flex.effects.Move"/>
     <component id="Resize" class="org.apache.flex.effects.Resize"/>
     <component id="Wipe" class="org.apache.flex.effects.Wipe"/>
     <component id="Sequence" class="org.apache.flex.effects.Sequence"/>
     <component id="Parallel" class="org.apache.flex.effects.Parallel"/>
+    <component id="CompoundEffect" 
class="org.apache.flex.effects.CompoundEffect"/>
     <component id="Transition" class="org.apache.flex.states.Transition" />
     <component id="EasyAccordionCollapseBead" 
class="org.apache.flex.effects.beads.EasyAccordionCollapseBead"/>
 

Reply via email to