Repository: flex-asjs
Updated Branches:
  refs/heads/develop e19deeda4 -> 7906ae7cc


EasyAccordionCollapseBead now works with layout tweener (works in flash, JS not 
tested).


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

Branch: refs/heads/develop
Commit: ae391650f8163b2249fea9d3cad8748ac6f2b8b6
Parents: 7ff7894
Author: yishayw <yishayj...@hotmail.com>
Authored: Tue Dec 13 17:29:38 2016 +0200
Committer: yishayw <yishayj...@hotmail.com>
Committed: Tue Dec 13 17:29:38 2016 +0200

----------------------------------------------------------------------
 .../flex/org/apache/flex/effects/Parallel.as    |   2 +-
 .../flex/org/apache/flex/utils/LayoutTweener.as | 152 ++++++++++
 .../org/apache/flex/utils/MockContentView.as    | 234 ++++++++++++++++
 .../org/apache/flex/utils/MockLayoutChild.as    | 272 ++++++++++++++++++
 .../org/apache/flex/utils/MockLayoutHost.as     |  37 +++
 .../org/apache/flex/utils/MockLayoutParent.as   | 276 +++++++++++++++++++
 .../flex/html/beads/AccordionCollapseBead.as    |   2 +-
 .../html/beads/EasyAccordionCollapseBead.as     |  72 ++---
 .../layouts/OneFlexibleChildVerticalLayout.as   |   5 +-
 9 files changed, 992 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ae391650/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Parallel.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Parallel.as 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Parallel.as
index 6d08012..4a2bdd6 100644
--- 
a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Parallel.as
+++ 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Parallel.as
@@ -94,7 +94,7 @@ public class Parallel extends Effect implements IDocument
     override public function set duration(value:Number):void
     {
         var n:int = children.length;
-        for (var i:int = 0; i < 0; i++)
+        for (var i:int = 0; i < n; i++)
         {
             children[i].duration = value;
         }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ae391650/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/LayoutTweener.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/LayoutTweener.as
 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/LayoutTweener.as
new file mode 100644
index 0000000..0e7a438
--- /dev/null
+++ 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/LayoutTweener.as
@@ -0,0 +1,152 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.utils
+{
+       import org.apache.flex.core.IBeadLayout;
+       import org.apache.flex.core.ILayoutChild;
+       import org.apache.flex.core.ILayoutParent;
+       import org.apache.flex.core.IParentIUIBase;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.IUIBase;
+       import org.apache.flex.effects.Effect;
+       import org.apache.flex.effects.Move;
+       import org.apache.flex.effects.Parallel;
+       import org.apache.flex.effects.Resize;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.events.EventDispatcher;
+
+       /**
+        * 
+        * @author Yishay
+        */
+       public class LayoutTweener extends EventDispatcher
+       {
+               private var sourceLayout:IBeadLayout;
+               private var sourceLayoutParent:ILayoutParent;
+               private var _mockLayoutParent:MockLayoutParent;
+               /**
+                * 
+                * @param sourceLayout
+                * @param sourceLayoutParent
+                */
+               public function LayoutTweener(sourceLayout:IBeadLayout, 
sourceLayoutParent:ILayoutParent)
+               {
+                       this.sourceLayout = sourceLayout;
+                       this.sourceLayoutParent = sourceLayoutParent;
+               }
+               
+               /**
+                * 
+                * @return 
+                */
+               public function get mockLayoutParent():MockLayoutParent
+               {
+                       return _mockLayoutParent;
+               }
+
+               /**
+                * 
+                */
+               public function setBaseline():void
+               {
+                       _mockLayoutParent = new 
MockLayoutParent(sourceLayoutParent);
+                       sourceLayout.strand = _mockLayoutParent as IStrand;
+               }
+               
+               /**
+                * 
+                * @return 
+                */
+               public function layout():Boolean
+               {
+                       setBaseline();
+                       var result:Boolean = sourceLayout.layout();
+                       play();
+                       return result;
+               }
+               
+               /**
+                * 
+                */
+               public function play():void
+               {
+                       var effects:Array = getEffects(sourceLayoutParent, 
mockLayoutParent);
+                       sourceLayout.strand = sourceLayoutParent as IStrand;
+                       if (effects && effects.length > 0)
+                       {
+                               var parallel:Parallel = new Parallel();
+                               parallel.children = effects;
+                               parallel.addEventListener(Effect.EFFECT_END, 
effectEndHandler);
+                               parallel.play();
+                       }
+               }
+               
+               /**
+                * 
+                * @param event
+                */
+               protected function effectEndHandler(event:Event):void
+               {
+                       dispatchEvent(event);
+               }
+               
+               private function getEffects(originalLayoutParent:ILayoutParent, 
mockLayoutParent:ILayoutParent):Array
+               {
+                       var originalContentView:IParentIUIBase = 
originalLayoutParent.getLayoutHost().contentView;
+                       var mockContentView:IParentIUIBase = 
mockLayoutParent.getLayoutHost().contentView;
+                       var numElements:int = originalContentView.numElements;
+                       var effects:Array = [];
+                       for (var i:int = 0; i < numElements; i++)
+                       {
+                               var originalChild:ILayoutChild = 
originalContentView.getElementAt(i) as ILayoutChild;
+                               var mockChild:ILayoutChild = 
mockContentView.getElementAt(i) as ILayoutChild;
+                               pushMove(originalChild, mockChild, effects);
+                               pushResize(originalChild, mockChild, effects);
+                       }
+                       return effects;
+               }
+               
+               private function pushResize(originalChild:ILayoutChild, 
mockChild:ILayoutChild, effects:Array):void
+               {
+                       var widthDiff:Number = mockChild.width - 
originalChild.width;
+                       var heightDiff:Number = mockChild.height - 
originalChild.height;
+                       if (widthDiff != 0 || heightDiff !=0)
+                       {
+                               var resize:Resize = new Resize(originalChild as 
IUIBase);
+                               resize.widthBy = widthDiff;
+                               resize.heightBy = heightDiff;
+                               effects.push(resize);
+                       }
+               }
+               
+               private function pushMove(originalChild:ILayoutChild, 
mockChild:ILayoutChild, effects:Array):void
+               {
+                       var xDiff:Number = mockChild.x - originalChild.x;
+                       var yDiff:Number = mockChild.y - originalChild.y;
+                       if (xDiff != 0 || yDiff !=0)
+                       {
+                               var move:Move = new Move(originalChild as 
IUIBase);
+                               move.xBy = xDiff;
+                               move.yBy = yDiff;
+                               effects.push(move);
+                       }
+               }
+               
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ae391650/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockContentView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockContentView.as
 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockContentView.as
new file mode 100644
index 0000000..d48e9f3
--- /dev/null
+++ 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockContentView.as
@@ -0,0 +1,234 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.utils
+{
+       import flash.display.DisplayObject;
+       import flash.events.Event;
+       
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.IChild;
+       import org.apache.flex.core.IContentView;
+       import org.apache.flex.core.ILayoutChild;
+       import org.apache.flex.core.IParent;
+       import org.apache.flex.core.IParentIUIBase;
+       import org.apache.flex.events.IEventDispatcher;
+       
+       public class MockContentView implements IContentView, IParentIUIBase
+       {
+               private var _x:Number;
+               private var _y:Number;
+               private var _width:Number;
+               private var _height:Number;
+               private var elements:Array = [];
+               
+               public function MockContentView(source:IParentIUIBase)
+               {
+                       x = source.x;
+                       y = source.y;
+                       width = source.width;
+                       height = source.height;
+                       for (var i:int = 0; i < source.numElements; i++)
+                       {
+                               var mock:ILayoutChild = new 
MockLayoutChild(source.getElementAt(i) as ILayoutChild);
+                               elements.push(mock);
+                       }
+               }
+               
+               public function get x():Number
+               {
+                       return _x;
+               }
+               
+               public function set x(value:Number):void
+               {
+                       _x = value;
+               }
+               
+               public function get y():Number
+               {
+                       return _y;
+               }
+               
+               public function set y(value:Number):void
+               {
+                       _y = value;
+               }
+               
+               public function get width():Number
+               {
+                       return _width;
+               }
+               
+               public function set width(value:Number):void
+               {
+                       _width = value;
+               }
+               
+               public function get height():Number
+               {
+                       return _height;
+               }
+               
+               public function set height(value:Number):void
+               {
+                       _height = value;
+               }
+               
+               public function removeAllElements():void
+               {
+                       elements = [];  
+               }
+               
+               public function addElement(c:IChild, 
dispatchEvent:Boolean=true):void
+               {
+                       elements.push(c);
+               }
+               
+               public function addElementAt(c:IChild, index:int, 
dispatchEvent:Boolean=true):void
+               {
+                       elements.splice(index, 0, c);
+               }
+               
+               public function getElementIndex(c:IChild):int
+               {
+                       return elements.indexOf(c);
+               }
+               
+               public function removeElement(c:IChild, 
dispatchEvent:Boolean=true):void
+               {
+                       var i:int = getElementIndex(c);
+                       elements.removeAt(i);
+               }
+               
+               public function get numElements():int
+               {
+                       return elements.length;
+               }
+               
+               public function getElementAt(index:int):IChild
+               {
+                       return elements[index] as IChild;
+               }
+               
+               COMPILE::JS
+               {
+                       public function internalChildren():Array
+                       {
+                               
+                       }
+               }
+
+               public function get $displayObject():DisplayObject
+               {
+                       // TODO Auto Generated method stub
+                       return null;
+               }
+               
+               public function addBead(bead:IBead):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function getBeadByType(classOrInterface:Class):IBead
+               {
+                       // TODO Auto Generated method stub
+                       return null;
+               }
+               
+               public function removeBead(bead:IBead):IBead
+               {
+                       // TODO Auto Generated method stub
+                       return null;
+               }
+               
+               public function addEventListener(type:String, 
listener:Function, useCapture:Boolean=false, priority:int=0, 
useWeakReference:Boolean=false):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function dispatchEvent(event:Event):Boolean
+               {
+                       // TODO Auto Generated method stub
+                       return false;
+               }
+               
+               public function hasEventListener(type:String):Boolean
+               {
+                       // TODO Auto Generated method stub
+                       return false;
+               }
+               
+               public function removeEventListener(type:String, 
listener:Function, useCapture:Boolean=false):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function willTrigger(type:String):Boolean
+               {
+                       // TODO Auto Generated method stub
+                       return false;
+               }
+               
+               public function get parent():IParent
+               {
+                       // TODO Auto Generated method stub
+                       return null;
+               }
+               
+               public function addedToParent():void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function get alpha():Number
+               {
+                       // TODO Auto Generated method stub
+                       return 0;
+               }
+               
+               public function set alpha(value:Number):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function get topMostEventDispatcher():IEventDispatcher
+               {
+                       // TODO Auto Generated method stub
+                       return null;
+               }
+               
+               public function set visible(value:Boolean):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function get visible():Boolean
+               {
+                       // TODO Auto Generated method stub
+                       return false;
+               }
+               
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ae391650/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutChild.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutChild.as
 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutChild.as
new file mode 100644
index 0000000..13c1a0b
--- /dev/null
+++ 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutChild.as
@@ -0,0 +1,272 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.utils
+{
+       COMPILE::SWF
+       {
+               import flash.display.DisplayObject;
+               import flash.events.Event;
+       }
+       
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.ILayoutChild;
+       import org.apache.flex.core.IParent;
+       import org.apache.flex.core.IStyleableObject;
+       import org.apache.flex.core.IUIBase;
+       import org.apache.flex.events.IEventDispatcher;
+       
+       public class MockLayoutChild implements ILayoutChild, IUIBase, 
IStyleableObject
+       {
+               private var _explicitHeight:Number;
+               private var _isHeightSizedToContent:Boolean;
+               private var _isWidthSizedToContent:Boolean;
+               private var _percentHeight:Number;
+               private var _height:Number;
+               private var _width:Number;
+               private var _x:Number;
+               private var _y:Number;
+               private var _percentWidth:Number;
+               private var _explicitWidth:Number;
+               private var _source:ILayoutChild;
+               private var _alpha:Number;
+               private var _visible:Boolean;
+               
+               public function MockLayoutChild(source:ILayoutChild)
+               {
+                       _source = source;
+                       _explicitHeight = source.explicitHeight;
+                       _explicitWidth = source.explicitWidth;
+                       _isHeightSizedToContent = 
source.isHeightSizedToContent();
+                       _isWidthSizedToContent = source.isWidthSizedToContent();
+                       _percentHeight = source.percentHeight;
+                       _percentWidth = source.percentWidth;
+                       _x = source.x;
+                       _y = source.y;
+                       _width = source.width;
+                       _height = source.height;
+                       _alpha = source.alpha;
+                       _visible = source.visible;
+               }
+               
+               public function get explicitHeight():Number
+               {
+                       return _explicitHeight;
+               }
+               
+               public function isHeightSizedToContent():Boolean
+               {
+                       return _isHeightSizedToContent;
+               }
+               
+               public function get percentHeight():Number
+               {
+                       return _percentHeight;
+               }
+               
+               public function set percentHeight(value:Number):void
+               {
+                       _percentHeight = value;
+               }
+               
+               public function setWidthAndHeight(newWidth:Number, 
newHeight:Number, noEvent:Boolean=false):void
+               {
+                       _width = newWidth;
+                       _height = newHeight;
+               }
+               
+               public function setHeight(value:Number, 
noEvent:Boolean=false):void
+               {
+                       _height = value;
+               }
+               
+               public function setX(value:Number):void
+               {
+                       _x = value;
+               }
+               
+               public function setY(value:Number):void
+               {
+                       _y = value;
+               }
+               
+               public function get percentWidth():Number
+               {
+                       return _percentWidth;
+               }
+               
+               public function set percentWidth(value:Number):void
+               {
+                       _percentWidth = value;
+               }
+               
+               public function setWidth(value:Number, 
noEvent:Boolean=false):void
+               {
+                       _width = value;
+               }
+               
+               public function get explicitWidth():Number
+               {
+                       return _explicitWidth;
+               }
+               
+               public function isWidthSizedToContent():Boolean
+               {
+                       return _isWidthSizedToContent;
+               }
+               
+               public function get parent():IParent
+               {
+                       return _source.parent;
+               }
+               
+               COMPILE::SWF
+               public function get $displayObject():DisplayObject
+               {
+                       return _source.$displayObject;
+               }
+               
+               public function addedToParent():void
+               {
+               }
+               
+               public function get alpha():Number
+               {
+                       return _alpha;
+               }
+               
+               public function set alpha(value:Number):void
+               {
+                       _alpha = value;
+               }
+               
+               public function get x():Number
+               {
+                       return _x;
+               }
+               
+               public function set x(value:Number):void
+               {
+                       _x = value;
+               }
+               
+               public function get y():Number
+               {
+                       return _y;
+               }
+               
+               public function set y(value:Number):void
+               {
+                       _y = value;
+               }
+               
+               public function get width():Number
+               {
+                       return _width;
+               }
+               
+               public function set width(value:Number):void
+               {
+                       _width = value;
+               }
+               
+               public function get height():Number
+               {
+                       return _height;
+               }
+               
+               public function set height(value:Number):void
+               {
+                       _height = value;
+               }
+               
+               public function get visible():Boolean
+               {
+                       return _visible;
+               }
+               
+               public function set visible(value:Boolean):void
+               {
+                       _visible = value;
+               }
+               
+               public function get topMostEventDispatcher():IEventDispatcher
+               {
+                       return _source.topMostEventDispatcher;
+               }
+               
+               public function addBead(bead:IBead):void
+               {
+               }
+               
+               public function getBeadByType(classOrInterface:Class):IBead
+               {
+                       return _source.getBeadByType(classOrInterface);
+               }
+               
+               public function removeBead(bead:IBead):IBead
+               {
+                       return null;
+               }
+               
+               public function addEventListener(type:String, 
listener:Function, useCapture:Boolean=false, priority:int=0, 
useWeakReference:Boolean=false):void
+               {
+               }
+               
+               public function removeEventListener(type:String, 
listener:Function, useCapture:Boolean=false):void
+               {
+               }
+               
+               COMPILE::SWF
+               public function dispatchEvent(event:Event):Boolean
+               {
+                       return false;
+               }
+               
+               public function hasEventListener(type:String):Boolean
+               {
+                       return _source.hasEventListener(type);
+               }
+               
+               public function willTrigger(type:String):Boolean
+               {
+                       return _source.willTrigger(type);
+               }
+               
+               public function get className():String
+               {
+                       return (_source as IStyleableObject).className;
+               }
+               
+               public function set className(value:String):void
+               {
+                       // TODO Auto Generated method stub
+               }
+               
+               public function get id():String
+               {
+                       return (_source as IStyleableObject).id;
+               }
+               
+               public function get style():Object
+               {
+                       return (_source as IStyleableObject).style;
+               }
+               
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ae391650/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutHost.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutHost.as
 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutHost.as
new file mode 100644
index 0000000..3f45b7e
--- /dev/null
+++ 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutHost.as
@@ -0,0 +1,37 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.utils
+{
+       import org.apache.flex.core.ILayoutHost;
+       import org.apache.flex.core.IParentIUIBase;
+       
+       public class MockLayoutHost implements ILayoutHost
+       {
+               private var _contentView:IParentIUIBase;
+               public function MockLayoutHost(source:ILayoutHost)
+               {
+                       _contentView = new MockContentView(source.contentView);
+               }
+               
+               public function get contentView():IParentIUIBase
+               {
+                       return _contentView;
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ae391650/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutParent.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutParent.as
 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutParent.as
new file mode 100644
index 0000000..e823087
--- /dev/null
+++ 
b/frameworks/projects/Effects/src/main/flex/org/apache/flex/utils/MockLayoutParent.as
@@ -0,0 +1,276 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.utils
+{
+       import flash.display.DisplayObject;
+       import flash.events.Event;
+       
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.ILayoutChild;
+       import org.apache.flex.core.ILayoutHost;
+       import org.apache.flex.core.ILayoutParent;
+       import org.apache.flex.core.IParent;
+       import org.apache.flex.core.IParentIUIBase;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.events.IEventDispatcher;
+       
+       public class MockLayoutParent implements ILayoutParent, ILayoutHost, 
IStrand, ILayoutChild
+       {
+               private var _layoutHost:ILayoutHost;
+               private var _source:ILayoutParent;
+               public function MockLayoutParent(source:ILayoutParent)
+               {
+                       _layoutHost = new 
MockLayoutHost(source.getLayoutHost());
+                       _source = source;
+               }
+               
+               public function get parent():IParent
+               {
+                       // TODO Auto Generated method stub
+                       return null;
+               }
+               
+               
+               public function addedToParent():void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function get alpha():Number
+               {
+                       // TODO Auto Generated method stub
+                       return 0;
+               }
+               
+               public function set alpha(value:Number):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function get height():Number
+               {
+                       // TODO Auto Generated method stub
+                       return 0;
+               }
+               
+               public function set height(value:Number):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function get topMostEventDispatcher():IEventDispatcher
+               {
+                       // TODO Auto Generated method stub
+                       return null;
+               }
+               
+               public function get visible():Boolean
+               {
+                       // TODO Auto Generated method stub
+                       return false;
+               }
+               
+               public function set visible(value:Boolean):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function get width():Number
+               {
+                       // TODO Auto Generated method stub
+                       return 0;
+               }
+               
+               public function set width(value:Number):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function get x():Number
+               {
+                       // TODO Auto Generated method stub
+                       return 0;
+               }
+               
+               public function set x(value:Number):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function get y():Number
+               {
+                       // TODO Auto Generated method stub
+                       return 0;
+               }
+               
+               public function set y(value:Number):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               
+               public function getLayoutHost():ILayoutHost
+               {
+                       return _layoutHost;
+               }
+               
+               public function get contentView():IParentIUIBase
+               {
+                       return _layoutHost.contentView;
+               }
+               
+               public function addBead(bead:IBead):void
+               {
+                       // TODO Auto Generated method stub
+               }
+               
+               public function getBeadByType(classOrInterface:Class):IBead
+               {
+                       return (_source as 
IStrand).getBeadByType(classOrInterface);    
+               }
+               
+               public function removeBead(bead:IBead):IBead
+               {
+                       // TODO Auto Generated method stub
+                       return null;
+               }
+               
+               public function get explicitHeight():Number
+               {
+                       // TODO Auto Generated method stub
+                       return 0;
+               }
+               
+               public function get explicitWidth():Number
+               {
+                       // TODO Auto Generated method stub
+                       return 0;
+               }
+               
+               public function isHeightSizedToContent():Boolean
+               {
+                       // TODO Auto Generated method stub
+                       return false;
+               }
+               
+               public function isWidthSizedToContent():Boolean
+               {
+                       // TODO Auto Generated method stub
+                       return false;
+               }
+               
+               public function get percentHeight():Number
+               {
+                       // TODO Auto Generated method stub
+                       return 0;
+               }
+               
+               public function set percentHeight(value:Number):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function get percentWidth():Number
+               {
+                       // TODO Auto Generated method stub
+                       return 0;
+               }
+               
+               public function set percentWidth(value:Number):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function setHeight(value:Number, 
noEvent:Boolean=false):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function setWidth(value:Number, 
noEvent:Boolean=false):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function setWidthAndHeight(newWidth:Number, 
newHeight:Number, noEvent:Boolean=false):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function setX(value:Number):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function setY(value:Number):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function addEventListener(type:String, 
listener:Function, useCapture:Boolean=false, priority:int=0, 
useWeakReference:Boolean=false):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function dispatchEvent(event:Event):Boolean
+               {
+                       // TODO Auto Generated method stub
+                       return false;
+               }
+               
+               public function hasEventListener(type:String):Boolean
+               {
+                       // TODO Auto Generated method stub
+                       return false;
+               }
+               
+               public function removeEventListener(type:String, 
listener:Function, useCapture:Boolean=false):void
+               {
+                       // TODO Auto Generated method stub
+                       
+               }
+               
+               public function willTrigger(type:String):Boolean
+               {
+                       // TODO Auto Generated method stub
+                       return false;
+               }
+               
+               public function get $displayObject():DisplayObject
+               {
+                       // TODO Auto Generated method stub
+                       return null;
+               }
+               
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ae391650/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/AccordionCollapseBead.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/AccordionCollapseBead.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/AccordionCollapseBead.as
index edc41e0..2dde93f 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/AccordionCollapseBead.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/AccordionCollapseBead.as
@@ -78,7 +78,7 @@ package org.apache.flex.html.beads
                        layout.layout();
                }
                
-               private function get layout():IOneFlexibleChildLayout
+               protected function get layout():IOneFlexibleChildLayout
                {
                        if (!_layout)
                        {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ae391650/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/EasyAccordionCollapseBead.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/EasyAccordionCollapseBead.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/EasyAccordionCollapseBead.as
index ec2098b..22c6f1c 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/EasyAccordionCollapseBead.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/EasyAccordionCollapseBead.as
@@ -20,29 +20,21 @@ package org.apache.flex.html.beads
 {
        
        import org.apache.flex.core.ILayoutChild;
+       import org.apache.flex.core.ILayoutParent;
        import org.apache.flex.core.UIBase;
-       import org.apache.flex.effects.Effect;
-       import org.apache.flex.effects.IEffect;
-       import org.apache.flex.effects.Parallel;
-       import org.apache.flex.effects.Resize;
-       import org.apache.flex.effects.Tween;
        import org.apache.flex.events.Event;
-       import org.apache.flex.events.ValueEvent;
        import org.apache.flex.html.beads.layouts.IOneFlexibleChildLayout;
        import org.apache.flex.html.supportClasses.ICollapsible;
+       import org.apache.flex.utils.LayoutTweener;
        
        public class EasyAccordionCollapseBead extends AccordionCollapseBead
        {
-               private var newChild:UIBase;
-               private var oldChild:UIBase;
-               private var resizeNew:Resize;
-               private var resizeOld:Resize;
                public function EasyAccordionCollapseBead()
                {
                        super();
                }
                
-               private function findPreviousNonCollapsed():ICollapsible
+               private function findPreviousNonCollapsedIndex():int
                {
                        var n:int = view.dataGroup.numElements;
                        for (var i:int = 0; i < n; i++)
@@ -50,10 +42,10 @@ package org.apache.flex.html.beads
                                var collapsible:ICollapsible = 
view.dataGroup.getElementAt(i) as ICollapsible;
                                if (collapsible.collapsedHeight != (collapsible 
as ILayoutChild).height)
                                {
-                                       return collapsible;
+                                       return i;
                                }
                        }
-                       return null;
+                       return -1;
                }
                
                private function get view():IListView
@@ -63,16 +55,21 @@ package org.apache.flex.html.beads
                
                override protected function 
selectedIndexChangedHandler(event:Event):void
                {
-                       newChild = 
view.dataGroup.getElementAt(host.selectedIndex) as UIBase;
-                       oldChild = findPreviousNonCollapsed() as UIBase;
-                       if (!newChild || !oldChild)
+                       var newChild:UIBase = 
view.dataGroup.getElementAt(host.selectedIndex) as UIBase;
+                       var oldChildIndex:int = findPreviousNonCollapsedIndex();
+                       var oldCollapsible:ICollapsible = 
view.dataGroup.getElementAt(oldChildIndex) as ICollapsible;
+                       if (!newChild || oldChildIndex < 0)
                        {
                                return;
                        }
-                       var effect:IEffect = getResize(newChild, oldChild);
-                       effect.addEventListener(Effect.EFFECT_END, 
effectEndHandler);
+                       var collapseHeight:Number = 
oldCollapsible.collapsedHeight;
+                       var tweener:LayoutTweener = new LayoutTweener(layout, 
host as ILayoutParent);
+                       tweener.setBaseline();
+                       var oldLayoutChild:ILayoutChild = 
tweener.mockLayoutParent.contentView.getElementAt(oldChildIndex) as 
ILayoutChild;
+                       oldLayoutChild.height = collapseHeight;
                        layout.flexibleChild = newChild.id;
-                       effect.play();
+                       layout.layout();
+                       tweener.play();
                }
                
                private function get layout():IOneFlexibleChildLayout
@@ -80,42 +77,5 @@ package org.apache.flex.html.beads
                        return (view as AccordionView).layout;
                }
                
-               protected function effectEndHandler(event:Event):void
-               {
-                       var parallel:Parallel = event.target as Parallel;
-                       parallel.removeEventListener(Effect.EFFECT_END, 
effectEndHandler);
-                       resizeNew.removeEventListener(Tween.TWEEN_UPDATE, 
newTweenUpdateHandler);
-                       resizeOld.removeEventListener(Tween.TWEEN_UPDATE, 
oldTweenUpdateHandler);
-                       resizeNew = null;
-                       resizeOld = null;
-                       newChild = null;
-                       oldChild = null;
-                       layout.layout();
-               }
-               
-               private function getResize(newChild:UIBase, 
oldChild:UIBase):IEffect
-               {
-                       resizeNew = new Resize(newChild);
-//                     resizeNew.duration = 3000;
-                       resizeNew.addEventListener(Tween.TWEEN_UPDATE, 
newTweenUpdateHandler);
-                       resizeNew.heightTo = oldChild.height;
-                       resizeOld = new Resize(oldChild);
-//                     resizeOld.duration = 3000;
-                       resizeOld.addEventListener(Tween.TWEEN_UPDATE, 
oldTweenUpdateHandler);
-                       resizeOld.heightTo = (oldChild as 
ICollapsible).collapsedHeight;
-                       var parallel:Parallel = new Parallel();
-                       parallel.children = [resizeNew, resizeOld];
-                       return parallel;
-               }
-               
-               protected function oldTweenUpdateHandler(event:ValueEvent):void
-               {
-                       oldChild.dispatchEvent(new Event("layoutNeeded"));
-               }
-               
-               protected function newTweenUpdateHandler(event:ValueEvent):void
-               {
-                       newChild.dispatchEvent(new Event("layoutNeeded"));
-               }
        }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ae391650/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
index 2688eee..a2ad24c 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
@@ -24,6 +24,7 @@ package org.apache.flex.html.beads.layouts
        import org.apache.flex.core.ILayoutParent;
        import org.apache.flex.core.IParentIUIBase;
        import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.IStyleableObject;
        import org.apache.flex.core.IUIBase;
        import org.apache.flex.core.UIBase;
        import org.apache.flex.core.ValuesManager;
@@ -160,10 +161,10 @@ package org.apache.flex.html.beads.layouts
                        var result:ILayoutChild;
                        for (var i:int = 0; i < contentView.numElements; i++)
                        {
-                               var child:UIBase = contentView.getElementAt(i) 
as UIBase;
+                               var child:IStyleableObject = 
contentView.getElementAt(i) as IStyleableObject;
                                if (child.id == id)
                                {
-                                       return child;
+                                       return child as ILayoutChild;
                                }
                        }
                        return null;

Reply via email to