| <?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. |
| |
| --> |
| |
| <!--This widget allows the user to enter a file name and when the "ReadFile" button is pressed, it |
| reads the file, and passes through the file contents as a ContentEvent. It expects an XML file in |
| TextLayout format.--> |
| |
| <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" creationComplete="handleCreationComplete()" > |
| <mx:Metadata> |
| [Event(name="fileChoose", type="textEditBar.FileEvent")] |
| [Event(name="textLayoutExport", type="flash.events.Event")] |
| [Event(name="htmlExport", type="flash.events.Event")] |
| </mx:Metadata> |
| |
| <mx:Script> |
| <![CDATA[ |
| import flash.events.Event; |
| import flash.system.Capabilities; |
| import flashx.textLayout.elements.TextFlow; |
| import mx.events.MenuEvent; |
| import mx.controls.Alert; |
| import flashx.textLayout.edit.EditingMode; |
| import flashx.textLayout.edit.ElementRange; |
| import flashx.textLayout.edit.ISelectionManager; |
| import flashx.textLayout.edit.IEditManager; |
| import flashx.textLayout.BuildInfo; |
| |
| public var activeFlow:TextFlow; |
| |
| [Bindable] |
| public var buildString:String = "Build: " + BuildInfo.kBuildNumber + "(" + Capabilities.version + ")"; |
| |
| internal function handleCreationComplete():void |
| { |
| buildLabel.left = (this.x + this.width - 20) - buildLabel.width; |
| } |
| // Update UI panel in response to change in selection |
| public function update(range:ElementRange):void |
| { |
| if (!activeFlow) |
| return; |
| |
| } |
| |
| private var fileReference:FileReference; |
| |
| public function currentFileName():String |
| { |
| return fileReference != null ? fileReference.name : null; |
| } |
| |
| public function openDialog():void |
| { |
| var markupFilter:FileFilter = new FileFilter("Documents","*.xml;*.fxg;*.html"); |
| fileReference = new FileReference(); |
| fileReference.browse([markupFilter]); |
| fileReference.addEventListener(Event.SELECT,onFileSelect); |
| } |
| |
| private function onFileSelect(event:Event):void |
| { |
| try { |
| dispatchEvent(new FileEvent(fileReference)); |
| //fileReference.load(); |
| } catch (err:Event) { |
| Alert.show(err.toString()); |
| } |
| } |
| |
| ]]> |
| </mx:Script> |
| |
| <mx:Button label="Open..." click="openDialog()"/> |
| |
| <mx:Button id="textLayoutExportButton" label="Markup..." click="dispatchEvent(new Event('textLayoutExport'))"/> |
| <mx:Button id="htmlExportButton" label="HTML Markup..." click="dispatchEvent(new Event('htmlExport'))"/> |
| |
| <mx:Label id="buildLabel" text="{buildString}" fontWeight="bold" paddingTop="3" paddingBottom="1"/> |
| </mx:HBox> |