| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| 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. |
| |
| --> |
| <c:TransitionTemplate xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:mx="library://ns.adobe.com/flex/mx" |
| xmlns:c="comps.*" |
| width="500" height="300" initialize="onInit()"> |
| <fx:Script> |
| <![CDATA[ |
| import mx.events.FlexEvent; |
| |
| protected function onInit():void |
| { |
| this.valueFunction = getX; |
| this.initTrans = initMove; |
| this.returnTrans = returnMove; |
| this.currentState = "One"; |
| } |
| |
| protected function getX() : Number { |
| var visible:Number = target.parent != null ? 1 : 0; |
| visible = visible + (target2.parent != null ? 2 : 0); |
| visible = visible + (target3.parent != null ? 4 : 0); |
| return visible; |
| } |
| |
| ]]> |
| </fx:Script> |
| |
| <fx:Declarations> |
| <s:Transition id="initMove" fromState="One" toState="Two" autoReverse="true"> |
| <s:Parallel> |
| <s:AddAction target="{target3}" duration="1000" |
| effectStart="effectStart(event)" |
| effectEnd="effectEnd(event)" |
| effectStop="effectStop(event)" |
| /> |
| <s:RemoveAction target="{target}" duration="1000" |
| effectStart="effectStart(event)" |
| effectEnd="effectEnd(event)" |
| effectStop="effectStop(event)" |
| /> |
| </s:Parallel> |
| </s:Transition> |
| <s:Transition id="returnMove" fromState="Two" toState="One" autoReverse="true"> |
| <s:Parallel> |
| <s:AddAction target="{target}" |
| effectStart="effectStart(event)" |
| effectEnd="effectEnd(event)" |
| effectStop="effectStop(event)" |
| /> |
| <s:RemoveAction target="{target3}" |
| effectStart="effectStart(event)" |
| effectEnd="effectEnd(event)" |
| effectStop="effectStop(event)" |
| /> |
| </s:Parallel> |
| </s:Transition> |
| </fx:Declarations> |
| <c:states> |
| <s:State name="One"/> |
| <s:State name="Two"/> |
| </c:states> |
| <mx:HBox> |
| <s:Group id="target" includeIn="One"> |
| <s:Rect width="50" height="50"> |
| <s:fill> |
| <s:SolidColor color="#FF0000"/> |
| </s:fill> |
| </s:Rect> |
| </s:Group> |
| <s:Group id="target2"> |
| <s:Rect width="50" height="50" > |
| <s:fill> |
| <s:SolidColor color="#00FF00"/> |
| </s:fill> |
| </s:Rect> |
| </s:Group> |
| <s:Group id="target3" includeIn="Two"> |
| <s:Rect width="50" height="50"> |
| <s:fill> |
| <s:SolidColor color="#0000FF"/> |
| </s:fill> |
| </s:Rect> |
| </s:Group> |
| </mx:HBox> |
| </c:TransitionTemplate> |