1////////////////////////////////////////////////////////////////////////////////
2//
3//  ADOBE SYSTEMS INCORPORATED
4//  Copyright 2005-2007 Adobe Systems Incorporated
5//  All Rights Reserved.
6//
7//  NOTICE: Adobe permits you to use, modify, and distribute this file
8//  in accordance with the terms of the license agreement accompanying it.
9//
10////////////////////////////////////////////////////////////////////////////////
11
12package mx.effects.effectClasses
13{
14
15import flash.events.Event;
16import mx.containers.Panel;
17import mx.core.Container;
18import mx.core.FlexGlobals;
19import mx.core.IUIComponent;
20import mx.core.ScrollPolicy;
21import mx.core.mx_internal;
22import mx.effects.EffectManager;
23import mx.events.EffectEvent;
24import mx.events.ResizeEvent;
25import mx.styles.IStyleClient;
26
27use namespace mx_internal;
28
29/**
30 *  The ResizeInstance class implements the instance class
31 *  for the Resize effect.
32 *  Flex creates an instance of this class when it plays a Resize effect;
33 *  you do not create one yourself.
34 *
35 *  <p>Every effect class that is a subclass of the TweenEffect class
36 *  supports the following events:</p>
37 *
38 *  <ul>
39 *    <li><code>tweenEnd</code>: Dispatched when the tween effect ends. </li>
40 *
41 *    <li><code>tweenUpdate</code>: Dispatched every time a TweenEffect
42 *      class calculates a new value.</li>
43 *  </ul>
44 *
45 *  <p>The event object passed to the event listener for these events is of type TweenEvent.
46 *  The TweenEvent class defines the property <code>value</code>, which contains
47 *  the tween value calculated by the effect.
48 *  For the Resize effect,
49 *  the <code>TweenEvent.value</code> property contains a 2-item Array, where: </p>
50 *  <ul>
51 *    <li>value[0]:Number  A value between the values of the <code>Resize.widthFrom</code>
52 *    and <code>Resize.widthTo</code> property.</li>
53 *
54 *    <li>value[1]:Number  A value between the values of the <code>Resize.heightFrom</code>
55 *    and <code>Resize.heightTo</code> property.</li>
56 *  </ul>
57 *
58 *  @see mx.effects.Resize
59 *  @see mx.events.TweenEvent
60 *
61 *  @langversion 3.0
62 *  @playerversion Flash 9
63 *  @playerversion AIR 1.1
64 *  @productversion Flex 3
65 */
66public class ResizeInstance extends TweenEffectInstance
67{
68    include "../../core/Version.as";
69
70	//--------------------------------------------------------------------------
71	//
72	//  Constructor
73	//
74	//--------------------------------------------------------------------------
75
76	/**
77	 *  Constructor.
78	 *
79	 *  @param target The Object to animate with this effect.
80	 *
81	 *  @langversion 3.0
82	 *  @playerversion Flash 9
83	 *  @playerversion AIR 1.1
84	 *  @productversion Flex 3
85	 */
86	public function ResizeInstance(target:Object)
87	{
88		super(target);
89
90		needToLayout = true;
91	}
92
93	//--------------------------------------------------------------------------
94	//
95	//  Variables
96	//
97	//--------------------------------------------------------------------------
98
99	/**
100	 *  @private
101	 */
102	private var restoreVisibleArray:Array;
103
104	/**
105	 *  @private
106	 */
107	private var restoreAutoLayoutArray:Array;
108
109	/**
110	 *  @private
111	 */
112	private var numHideEffectsPlaying:Number = 0;
113
114	/**
115	 *  @private
116	 */
117	private var origPercentHeight:Number;
118
119	/**
120	 *  @private
121	 */
122	private var origPercentWidth:Number;
123
124	/**
125	 *  @private
126	 */
127	private var origExplicitHeight:Number;
128
129	/**
130	 *  @private
131	 */
132	private var origExplicitWidth:Number;
133
134	/**
135	 *  @private
136	 */
137	private var heightSet:Boolean;
138
139	/**
140	 *  @private
141	 */
142	private var widthSet:Boolean;
143
144	/**
145	 *  @private
146	 */
147	private var explicitWidthSet:Boolean;
148
149	/**
150	 *  @private
151	 */
152	private var explicitHeightSet:Boolean;
153
154	/**
155	 *  @private
156	 */
157	private var origVerticalScrollPolicy:String = "";
158
159	/**
160	 *  @private
161	 */
162	private var origHorizontalScrollPolicy:String = "";
163
164	/**
165	 *  @private
166	 */
167	private var parentOrigVerticalScrollPolicy:String = "";
168
169	/**
170	 *  @private
171	 */
172	private var parentOrigHorizontalScrollPolicy:String = "";
173
174	/**
175	 *  @private
176	 *  Stores the left style of the target
177	 */
178	private var left:*;
179
180	/**
181	 *  @private
182	 *  Stores the right style of the target
183	 */
184	private var right:*;
185
186	/**
187	 *  @private
188	 *  Stores the top style of the target
189	 */
190	private var top:*;
191
192	/**
193	 *  @private
194	 *  Stores the bottom style of the target
195	 */
196	private var bottom:*;
197
198	//--------------------------------------------------------------------------
199	//
200	//  Properties
201	//
202	//--------------------------------------------------------------------------
203
204	//----------------------------------
205	//  heightBy
206	//----------------------------------
207
208	/**
209	 *  @private
210	 *  Storage for the heightBy property.
211	 */
212	private var _heightBy:Number;
213
214	/**
215	 *  Number of pixels by which to modify the height of the component.
216	 *  Values may be negative.
217	 *
218	 *  @langversion 3.0
219	 *  @playerversion Flash 9
220	 *  @playerversion AIR 1.1
221	 *  @productversion Flex 3
222	 */
223	public function get heightBy():Number
224	{
225		return _heightBy;
226	}
227
228	/**
229	 *  @private
230	 */
231	public function set heightBy(value:Number):void
232	{
233		_heightBy = value;
234		heightSet = !isNaN(value);
235	}
236
237	//----------------------------------
238	//  heightFrom
239	//----------------------------------
240
241	/**
242	 *  Initial height. If omitted, Flex uses the current size.
243	 *
244	 *  @langversion 3.0
245	 *  @playerversion Flash 9
246	 *  @playerversion AIR 1.1
247	 *  @productversion Flex 3
248	 */
249	public var heightFrom:Number;
250
251	//----------------------------------
252	//  heightTo
253	//----------------------------------
254
255	/**
256	 *  @private
257	 *  Storage for the heightTo property.
258	 */
259	private var _heightTo:Number;
260
261	/**
262	 *  Final height, in pixels.
263	 *
264	 *  @langversion 3.0
265	 *  @playerversion Flash 9
266	 *  @playerversion AIR 1.1
267	 *  @productversion Flex 3
268	 */
269	public function get heightTo():Number
270	{
271		return _heightTo;
272	}
273
274	/**
275	 *  @private
276	 */
277	public function set heightTo(value:Number):void
278	{
279		_heightTo = value;
280		heightSet = !isNaN(value);
281	}
282
283	//----------------------------------
284	//  hideChildrenTargets
285	//----------------------------------
286
287	/**
288	 *  An Array of Panels.
289	 *  The children of these Panels are hidden while the Resize effect plays.
290	 *
291	 *  @langversion 3.0
292	 *  @playerversion Flash 9
293	 *  @playerversion AIR 1.1
294	 *  @productversion Flex 3
295	 */
296	public var hideChildrenTargets:Array /* of Panel */;
297
298	//----------------------------------
299	//  widthBy
300	//----------------------------------
301
302	/**
303	 *  @private
304	 *  Storage for the widthBy property.
305	 */
306	private var _widthBy:Number;
307
308	/**
309	 *  Number of pixels by which to modify the width of the component.
310	 *  Values may be negative.
311	 *
312	 *  @langversion 3.0
313	 *  @playerversion Flash 9
314	 *  @playerversion AIR 1.1
315	 *  @productversion Flex 3
316	 */
317	public function get widthBy():Number
318	{
319		return _widthBy;
320	}
321
322	/**
323	 *  @private
324	 */
325	public function set widthBy(value:Number):void
326	{
327		_widthBy = value;
328		widthSet = !isNaN(value);
329	}
330
331	//----------------------------------
332	//  widthFrom
333	//----------------------------------
334
335	/**
336	 *  Initial width. If omitted, Flex uses the current size.
337	 *
338	 *  @langversion 3.0
339	 *  @playerversion Flash 9
340	 *  @playerversion AIR 1.1
341	 *  @productversion Flex 3
342	 */
343	public var widthFrom:Number;
344
345	//----------------------------------
346	//  widthTo
347	//----------------------------------
348
349	/**
350	 *  @private
351	 *  Storage for the widthTo property.
352	 */
353	private var _widthTo:Number;
354
355	/**
356	 *  Final width, in pixels.
357	 *
358	 *  @langversion 3.0
359	 *  @playerversion Flash 9
360	 *  @playerversion AIR 1.1
361	 *  @productversion Flex 3
362	 */
363	public function get widthTo():Number
364	{
365		return _widthTo;
366	}
367
368	/**
369	 *  @private
370	 */
371	public function set widthTo(value:Number):void
372	{
373		_widthTo = value;
374		widthSet = !isNaN(value);
375	}
376
377	//--------------------------------------------------------------------------
378	//
379	//  Overridden methods
380	//
381	//--------------------------------------------------------------------------
382
383	/**
384	 *  @private
385	 */
386	override public function initEffect(event:Event):void
387	{
388		super.initEffect(event);
389
390		if (event is ResizeEvent && event.type == ResizeEvent.RESIZE)
391		{
392			if (isNaN(widthBy))
393			{
394				if (isNaN(widthFrom))
395				{
396					widthFrom = ResizeEvent(event).oldWidth;
397				}
398				if (isNaN(widthTo))
399				{
400					_widthTo = target.width;
401				}
402			}
403
404			if (isNaN(heightBy))
405			{
406				if (isNaN(heightFrom))
407				{
408					heightFrom = ResizeEvent(event).oldHeight;
409				}
410
411				if (isNaN(heightTo))
412				{
413					_heightTo = target.height;
414				}
415			}
416		}
417	}
418
419	/**
420	 *  @private
421	 */
422	override public function play():void
423	{
424		// Dispatch an effectStart event from the target.
425		super.play();
426
427		calculateExplicitDimensionChanges();
428
429		// If the target is a Panel, then find all Panel objects that will
430		// be affected by the animation.  Deliver a "resizeStart" event to
431		// each affected Panel, and then wait until the Panel finishes
432		// hiding its children.
433		var childrenHiding:Boolean = hidePanelChildren();
434
435		if (target is IStyleClient)
436		{
437			left = target.getStyle("left");
438			if (left != undefined)
439				target.setStyle("left",undefined);
440
441			right = target.getStyle("right");
442			if (right != undefined)
443				target.setStyle("right",undefined);
444
445			top = target.getStyle("top");
446			if (top != undefined)
447				target.setStyle("top",undefined);
448
449			bottom = target.getStyle("bottom");
450			if (bottom != undefined)
451				target.setStyle("bottom",undefined);
452		}
453
454		if (!childrenHiding)
455			startResizeTween();
456	}
457
458	/**
459	 *  @private
460     */
461	override public function onTweenUpdate(value:Object):void
462	{
463		EffectManager.suspendEventHandling();
464
465		// Use Math.round instead of Math.floor, so that the animation appears
466		// to begin playing after the value has changed by only half a pixel,
467		// instead of waiting for it to change by a whole pixel.
468		// Because of the way that the easing function mimics acceleration,
469		// it can take a while for the animation to get started.
470		target.width = Math.round(value[0]);
471		target.height = Math.round(value[1]);
472
473		// Set a flag indicating that LayoutManager.validateNow()
474		// should be called after we're finished processing
475		// all the effects for this frame.
476		if (tween)
477			tween.needToLayout = true;
478		needToLayout = true;
479
480		EffectManager.resumeEventHandling();
481	}
482
483	/**
484	 *  @private
485     */
486	override public function onTweenEnd(value:Object):void
487	{
488		EffectManager.endVectorEffect(IUIComponent(target));
489
490		// Wait a frame before starting to restore the childrens' visibility.
491		// That way, we have a chance to run a measurement/layout pass with
492		// the final sizes and update the screen.
493		FlexGlobals.topLevelApplication.callLater(restorePanelChildren);
494
495		super.onTweenEnd(value);
496
497		EffectManager.suspendEventHandling();
498
499		var targetAsContainer:Container;
500		var parentAsContainer:Container;
501
502		// Restore the target's percent and explicit sizes
503		if (!heightSet)
504		{
505			target.percentHeight = origPercentHeight;
506			target.explicitHeight = origExplicitHeight;
507
508			if (origVerticalScrollPolicy != "")
509			{
510				targetAsContainer = target as Container;
511				if (targetAsContainer)
512				{
513					targetAsContainer.verticalScrollPolicy = origVerticalScrollPolicy;
514					origVerticalScrollPolicy = "";
515				}
516			}
517
518			if (parentOrigVerticalScrollPolicy != "" && target.parent)
519			{
520				parentAsContainer = target.parent as Container;
521				if (parentAsContainer)
522				{
523					parentAsContainer.verticalScrollPolicy = parentOrigVerticalScrollPolicy;
524					parentOrigVerticalScrollPolicy = "";
525				}
526			}
527		}
528
529		if (!widthSet)
530		{
531			target.percentWidth = origPercentWidth;
532			target.explicitWidth = origExplicitWidth;
533
534			if (origHorizontalScrollPolicy != "")
535			{
536				targetAsContainer = target as Container;
537				if (targetAsContainer)
538				{
539					targetAsContainer.horizontalScrollPolicy = origHorizontalScrollPolicy;
540					origHorizontalScrollPolicy = "";
541				}
542			}
543
544			if (parentOrigHorizontalScrollPolicy != "" && target.parent)
545			{
546				parentAsContainer = target.parent as Container;
547				if (parentAsContainer)
548				{
549					parentAsContainer.horizontalScrollPolicy = parentOrigHorizontalScrollPolicy;
550					parentOrigHorizontalScrollPolicy = "";
551				}
552			}
553		}
554
555		if (left != undefined)
556			target.setStyle("left",left);
557		if (right != undefined)
558			target.setStyle("right",right);
559		if (top != undefined)
560			target.setStyle("top",top);
561		if (bottom != undefined)
562			target.setStyle("bottom",bottom);
563
564		EffectManager.resumeEventHandling();
565	}
566
567	/**
568	 *  @private
569     */
570	override public function end():void
571	{
572		// If we were waiting for the initial "hide children" effect to
573		// finish playing, then the tween might not be created yet.
574		// In that case, we need to explicitly jump to the end of the Resize,
575		// because the TweenEffect.end() function won't do it for us.
576
577		if (!tween)
578		{
579			calculateExplicitDimensionChanges();
580
581			onTweenEnd(playReversed ?
582					   [ widthFrom, heightFrom ] :
583					   [ widthTo, heightTo ]);
584		}
585
586
587		super.end();
588	}
589
590	//--------------------------------------------------------------------------
591	//
592	//  Methods
593	//
594	//--------------------------------------------------------------------------
595
596	/**
597	 *  @private
598	 */
599	private function startResizeTween():void
600	{
601		EffectManager.startVectorEffect(IUIComponent(target));
602
603		// Create a tween to resize the object
604		tween = createTween(this, [ widthFrom, heightFrom ],
605										 [ widthTo, heightTo ], duration);
606
607		// Set back to initial size before the screen refreshes.
608		//EffectManager.suspendEventHandling();
609		applyTweenStartValues();
610		/*if (needToLayout)
611			UIComponent.layoutManager.validateNow();
612		*
613		*  @langversion 3.0
614		*  @playerversion Flash 9
615		*  @playerversion AIR 1.1
616		*  @productversion Flex 3
617		*/
618		//EffectManager.resumeEventHandling();
619	}
620
621
622	/**
623	 *  @private
624	 *  Hides children of Panels while the effect is playing.
625	 */
626	private function hidePanelChildren():Boolean
627	{
628		if (!hideChildrenTargets)
629			return false;
630
631		// Initialize a couple arrays that will be needed later
632		restoreVisibleArray = [];
633		restoreAutoLayoutArray = [];
634
635		// Send each panel a "resizeStart" event, which will trigger
636		// the resizeStartEffect (if any)
637		var n:int = hideChildrenTargets.length;
638		for (var i:int = 0; i < n; i++)
639		{
640			var p:Object = hideChildrenTargets[i];
641
642			if (p is Panel)
643			{
644				var prevNumHideEffectsPlaying:Number = numHideEffectsPlaying;
645
646				p.addEventListener(EffectEvent.EFFECT_START, eventHandler);
647				p.dispatchEvent(new Event("resizeStart"));
648				p.removeEventListener(EffectEvent.EFFECT_START, eventHandler);
649
650				// If no effect started playing, then make children invisible
651				// immediately instead of waiting for the end of the effect
652				if (numHideEffectsPlaying == prevNumHideEffectsPlaying)
653					makePanelChildrenInvisible(Panel(p), i);
654			}
655		}
656
657		return numHideEffectsPlaying > 0;
658	}
659
660	/**
661	 *  @private
662	 */
663	private function makePanelChildrenInvisible(panel:Container,
664												panelIndex:Number):void
665	{
666		var childArray:Array = [];
667
668		var child:IUIComponent;
669
670		// Hide the Panel's children while the Resize is occurring.
671		var n:int = panel.numChildren;
672		for (var i:int = 0; i < n; i++)
673		{
674			child = IUIComponent(panel.getChildAt(i));
675			if (child.visible)
676			{
677				childArray.push(child);
678				child.setVisible(false, true);
679			}
680		}
681
682		// Hide the Panel's scrollbars while the Resize is occurring.
683		child = panel.horizontalScrollBar;
684		if (child && child.visible)
685		{
686			childArray.push(child);
687			child.setVisible(false, true);
688		}
689		child = panel.verticalScrollBar;
690		if (child && child.visible)
691		{
692			childArray.push(child);
693			child.setVisible(false, true);
694		}
695
696		restoreVisibleArray[panelIndex] = childArray;
697
698		// Set autoLayout = false, which prevents the Panel's updateDisplayList()
699		// method from executing while the Panel is resizing.
700		if (panel.autoLayout)
701		{
702			panel.autoLayout = false;
703			restoreAutoLayoutArray[panelIndex] = true;
704		}
705	}
706
707	/**
708	 * Method is used to explicitely determine widthTo and heightTo, taking into
709	 * account the current state of the component and the inputs to this ResizeEffect
710	 *
711	 * @private
712	 */
713	private function calculateExplicitDimensionChanges():void
714	{
715		var explicitWidth:* = propertyChanges ? propertyChanges.end["explicitWidth"] : undefined;
716		var explicitHeight:* = propertyChanges ? propertyChanges.end["explicitHeight"] : undefined;
717		var percentWidth:* = propertyChanges ? propertyChanges.end["percentWidth"] : undefined;
718		var percentHeight:* = propertyChanges ? propertyChanges.end["percentHeight"] : undefined;
719
720		var targetAsContainer:Container;
721		var parentAsContainer:Container;
722
723		if (!heightSet)
724		{
725			// Determine the percentHeight/explicitHeight to apply to target when effect ends
726			if (percentHeight !== undefined)
727				origPercentHeight = percentHeight;
728			else
729				origPercentHeight = target.percentHeight;
730
731			if (isNaN(origPercentHeight))
732			{
733				if (explicitHeight !== undefined)
734					origExplicitHeight = explicitHeight;
735				else
736					origExplicitHeight = target.explicitHeight;
737			}
738
739			targetAsContainer = target as Container;
740			if (targetAsContainer && targetAsContainer.verticalScrollBar == null)
741			{
742				origVerticalScrollPolicy = targetAsContainer.verticalScrollPolicy;
743				targetAsContainer.verticalScrollPolicy = ScrollPolicy.OFF;
744			}
745
746			if (target.parent)
747			{
748				parentAsContainer = target.parent as Container;
749				if (parentAsContainer && parentAsContainer.verticalScrollBar == null)
750				{
751					parentOrigVerticalScrollPolicy = parentAsContainer.verticalScrollPolicy;
752					parentAsContainer.verticalScrollPolicy = ScrollPolicy.OFF;
753				}
754			}
755		}
756
757		if (!widthSet)
758		{
759			// Determine the percentHeight/explicitHeight to apply to target when effect ends
760			if (percentWidth !== undefined)
761				origPercentWidth = percentWidth;
762			else
763				origPercentWidth = target.percentWidth;
764
765			if (isNaN(origPercentWidth))
766			{
767				if (explicitWidth !== undefined)
768					origExplicitWidth = explicitWidth;
769				else
770					origExplicitWidth = target.explicitWidth;
771			}
772
773			targetAsContainer = target as Container;
774			if (targetAsContainer && targetAsContainer.horizontalScrollBar == null)
775			{
776				origHorizontalScrollPolicy = targetAsContainer.horizontalScrollPolicy;
777				targetAsContainer.horizontalScrollPolicy = ScrollPolicy.OFF;
778			}
779
780			if (target.parent)
781			{
782				parentAsContainer = target.parent as Container;
783				if (parentAsContainer && parentAsContainer.horizontalScrollBar == null)
784				{
785					parentOrigHorizontalScrollPolicy = parentAsContainer.horizontalScrollPolicy;
786					parentAsContainer.horizontalScrollPolicy = ScrollPolicy.OFF;
787				}
788			}
789		}
790
791		// The user may have supplied some combination of widthFrom,
792		// widthTo, and widthBy. If either widthFrom or widthTo is
793		// not explicitly defined, calculate its value based on the
794		// other two values.
795		if (isNaN(widthFrom))
796		{
797            if (!isNaN(widthTo) && !isNaN(widthBy))
798                widthFrom = widthTo - widthBy;
799            else if (propertyChanges && propertyChanges.start["width"] != undefined)
800                widthFrom = propertyChanges.start["width"];
801            else
802				widthFrom = target.width;
803		}
804		if (isNaN(widthTo))
805		{
806			if (isNaN(widthBy) &&
807				propertyChanges &&
808				(propertyChanges.end["width"] !== undefined ||
809				 explicitWidth !== undefined ))
810			{
811				if (explicitWidth !== undefined && !isNaN(explicitWidth))
812				{
813					explicitWidthSet = true;
814					_widthTo = explicitWidth;
815				}
816				else
817				{
818					_widthTo = propertyChanges.end["width"];
819				}
820			}
821			else
822			{
823				_widthTo = (!isNaN(widthBy)) ?
824						  widthFrom + widthBy :
825						  target.width;
826			}
827		}
828
829		// Ditto for heightFrom, heightTo, and heightBy.
830		if (isNaN(heightFrom))
831		{
832            if (!isNaN(heightTo) && !isNaN(heightBy))
833                heightFrom = heightTo - heightBy;
834            else if (propertyChanges && propertyChanges.start["height"] != undefined)
835                heightFrom = propertyChanges.start["height"];
836            else
837                heightFrom = target.height;
838		}
839		if (isNaN(heightTo))
840		{
841			if (isNaN(heightBy) &&
842				propertyChanges &&
843				(propertyChanges.end["height"] !== undefined ||
844				 explicitHeight !== undefined))
845			{
846				if (explicitHeight !== undefined && !isNaN(explicitHeight))
847				{
848					explicitHeightSet = true;
849					_heightTo = explicitHeight;
850				}
851				else
852				{
853					_heightTo = propertyChanges.end["height"];
854				}
855			}
856			else
857			{
858				_heightTo = (!isNaN(heightBy))?
859						   heightFrom + heightBy :
860						   target.height;
861			}
862		}
863	}
864
865	/**
866	 *  @private
867	 */
868	private function restorePanelChildren():void
869	{
870		if (hideChildrenTargets)
871		{
872			var n:int = hideChildrenTargets.length;
873			for (var i:int = 0; i < n; i++)
874			{
875				var p:IUIComponent = hideChildrenTargets[i];
876
877				var childArray:Array = restoreVisibleArray[i];
878				if (childArray)
879				{
880					var m:int = childArray.length;
881					for (var j:int = 0; j < m; j++)
882					{
883						childArray[j].setVisible(true, true);
884					}
885				}
886
887				if (restoreAutoLayoutArray[i])
888					Container(p).autoLayout = true;
889
890				// Trigger the resizeEndEffect (if any)
891				p.dispatchEvent(new Event("resizeEnd"));
892			}
893		}
894	}
895
896	//--------------------------------------------------------------------------
897	//
898	//  Overridden event handlers
899	//
900	//--------------------------------------------------------------------------
901
902	/**
903	 *  @private
904	 *  This function is called when one of the Panels finishes
905	 *  its "hide children" animation.
906	 */
907	override mx_internal function eventHandler(event:Event):void
908	{
909		var panel:Container = event.target as Container;
910
911		super.eventHandler(event);
912
913		if (event.type == EffectEvent.EFFECT_START)
914		{
915			// Call my eventHandler() method when the effect finishes playing.
916			panel.addEventListener(EffectEvent.EFFECT_END, eventHandler);
917
918			// Remember how many effects we're waiting for
919			numHideEffectsPlaying++;
920		}
921
922		else if (event.type == EffectEvent.EFFECT_END)
923		{
924			// Remove the event listener that triggered this callback.
925			panel.removeEventListener(EffectEvent.EFFECT_END, eventHandler);
926
927			// Get the array index of the panel
928			var n:int = hideChildrenTargets.length;
929			for (var i:int = 0; i < n; i++)
930			{
931				if (hideChildrenTargets[i] == panel)
932					break;
933			}
934
935			makePanelChildrenInvisible(panel, i);
936
937			// If all panels have finished their "hide children" effect,
938			// then it's time to start our Resize effect.
939			if (--numHideEffectsPlaying == 0)
940				startResizeTween();
941		}
942	}
943}
944
945}
946