| <?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. |
| |
| --> |
| <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" add="addedHandler()" |
| xmlns:s="library://ns.adobe.com/flex/spark" title="Fade" backgroundColor="#3f3f3f"> |
| |
| <s:navigationContent> |
| <s:Button label="Back" click="navigator.popView();"/> |
| </s:navigationContent> |
| |
| <s:actionContent> |
| <s:Button label="Home" left="0" click="navigator.popToFirstView();"/> |
| </s:actionContent> |
| |
| <fx:Script> |
| <![CDATA[ |
| import spark.transitions.CrossFadeViewTransition; |
| import spark.transitions.ViewTransitionBase; |
| import mx.graphics.SolidColor; |
| |
| private function popCurrentView():void |
| { |
| saveData(); |
| navigator.popView(createTransition()); |
| } |
| |
| private function pushNextView():void |
| { |
| saveData(); |
| var newData:Object = new Object(); |
| newData.depth = data.depth + 1; |
| navigator.pushView(FadeTransitionView, newData, null, createTransition()); |
| } |
| |
| private function createTransition():ViewTransitionBase |
| { |
| var crossFade:CrossFadeViewTransition = new CrossFadeViewTransition(); |
| crossFade.duration = Number(duration.text); |
| return crossFade; |
| } |
| |
| private function saveData():void |
| { |
| data.duration = duration.text; |
| } |
| |
| private function addedHandler():void |
| { |
| if (data.depth) |
| title = "Fade " + data.depth; |
| |
| ellipse.fill = new SolidColor(Math.round( Math.random()*0xFFFFFF )); |
| var depth:Number = data.hasOwnProperty("depth") ? data.depth : 1; |
| data.depth = depth; |
| depthLabel.text = String(depth); |
| |
| } |
| ]]> |
| </fx:Script> |
| |
| <s:VGroup left="0" top="0" right="0" bottom="0" paddingTop="20" paddingLeft="20" paddingRight="20"> |
| <s:HGroup verticalAlign="middle"> |
| <s:Label text="Duration (ms):"/> |
| <s:TextInput id="duration" text="400" width="200"/> |
| </s:HGroup> |
| |
| <s:Rect height="100"/> |
| |
| <s:Group width="100%" height="200"> |
| <s:Ellipse width="200" height="200" verticalCenter="0" horizontalCenter="0" id="ellipse"/> |
| <s:Label verticalCenter="0" horizontalCenter="0" fontSize="70" id="depthLabel"/> |
| </s:Group> |
| |
| |
| |
| |
| </s:VGroup> |
| |
| <s:HGroup bottom="0" width="100%" gap="0" > |
| <s:Button label="PopView" width="100%" click="popCurrentView();" styleName="footer"/> |
| <s:Button label="PushView" width="100%" styleName="footer" click="pushNextView()"/> |
| </s:HGroup> |
| |
| <!--<s:Button width="100%" height="100%" label="AAA"/>--> |
| |
| </s:View> |