| <?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:Group 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="com.flexcapacitor.controls.*" |
| |
| creationComplete="creationCompleteHandler(event)"> |
| |
| |
| <!-- |
| |
| --> |
| <fx:Script> |
| <![CDATA[ |
| import com.flexcapacitor.controller.Radiate; |
| import com.flexcapacitor.events.RadiateEvent; |
| |
| import mx.events.FlexEvent; |
| |
| |
| |
| private var radiate:Radiate = Radiate.instance; |
| |
| protected function creationCompleteHandler(event:FlexEvent):void { |
| radiate.addEventListener(RadiateEvent.HISTORY_CHANGE, historyChangeHandler, false, 0, true); |
| |
| updateNavigationButtons(); |
| } |
| |
| /** |
| * History changed. Select the last applied item in the history array. |
| * */ |
| protected function historyChangeHandler(event:Event):void { |
| updateNavigationButtons(); |
| } |
| |
| /** |
| * |
| * */ |
| public function redo():void { |
| var historyIndex:int = Radiate.redo(true); |
| |
| |
| //Radiate.history.refresh(); |
| |
| //list.selectedIndex = historyIndex; |
| |
| updateNavigationButtons(); |
| |
| } |
| |
| /** |
| * |
| * */ |
| public function undo():void { |
| var historyIndex:int = Radiate.undo(true); |
| |
| //Radiate.history.refresh(); |
| |
| //list.selectedIndex = Radiate.historyIndex; |
| |
| updateNavigationButtons(); |
| } |
| |
| public function updateNavigationButtons():void { |
| var historyIndex:int = Radiate.historyIndex; |
| var totalItems:int = Radiate.history ? Radiate.history.length : 0; |
| var hasItems:Boolean = totalItems>0; |
| |
| // has forward history |
| if (hasItems && historyIndex+1<totalItems) { |
| forwardButton.enabled = true; |
| } |
| else { |
| forwardButton.enabled = false; |
| } |
| |
| // has previous items |
| if (hasItems && historyIndex>-1) { |
| backButton.enabled = true; |
| } |
| else { |
| backButton.enabled = false; |
| } |
| } |
| ]]> |
| </fx:Script> |
| |
| |
| <s:layout> |
| <s:HorizontalLayout paddingTop="4" verticalAlign="baseline" /> |
| </s:layout> |
| |
| <c:ImageButton id="backButton" source="{Radii8LibraryAssets.undo}" |
| height="15" |
| alpha=".8" |
| click="undo()" |
| /> |
| <c:ImageButton id="forwardButton" source="{Radii8LibraryAssets.redo}" |
| height="15" |
| alpha=".8" |
| click="redo()" |
| /> |
| </s:Group> |