Menu

[r11]: / trunk / SWFInvestigator / src / popUps / GetFileLocation.as  Maximize  Restore  History

Download this file

174 lines (146 with data), 5.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/****************************************************************************
* ADOBE SYSTEMS INCORPORATED
* Copyright 2012 Adobe Systems Incorporated and it’s licensors
* All Rights Reserved.
*
* NOTICE: Adobe permits you to use, modify, and distribute this file
* in accordance with the terms of the license agreement accompanying it.
* ****************************************************************************/
/**
* This is currently dead code. Native browse dialogues via FileActions are now used in most cases.
*/
package popUps
{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import spark.components.Panel;
import spark.components.VGroup;
import spark.components.Button;
import spark.components.Label;
import spark.components.TextInput;
import spark.layouts.HorizontalLayout;
import mx.events.FileEvent;
import mx.managers.PopUpManager;
import mx.controls.FileSystemTree;
/**
* Dispatched when the user chooses to Open the selected URL
*
* @eventType PopUp.PopUpReturnEvent.PARAMS_RETURNED
*/
[Event(name="fileReturned", type="popUps.PopUpReturnEvent")]
/**
* The GetSWFUrl class creates a PopUp to obtain the URL of the SWF from the user.
*
* GetSWFUrl will dispatch an event when the user has completed entering in the data.
*/
public class GetFileLocation extends Sprite
{
/**
* @private
* A pointer to the PopUp panel
*/
private var panel:Panel;
/**
* The default fileLocation for the text box
*/
public var fileLocation:String = "";
/**
* @private
* The TextInput box containing the fileLocation
*/
private var textInput:TextInput = new TextInput();
/**
* @private
* The FileSystemTree navigator
*/
private var fileSysTree:FileSystemTree = new FileSystemTree();
public function GetFileLocation(extArray:Array) {
var vb:VGroup = new VGroup();
var label:Label = new Label();
var b1:Button = new Button();
var b2:Button = new Button();
//Create buttons
b1.label = "Select";
b1.addEventListener(MouseEvent.CLICK, closeAndSave);
b2.label = "Cancel";
b2.addEventListener(MouseEvent.CLICK, closePopUp);
//Add to the Control Bar for the bottom
var cb:Array = new Array();
cb.push(b1);
cb.push(b2);
//Create the File Entry panel
label.text = "Please double-click the file to open:";
this.textInput.text = this.fileLocation;
this.textInput.percentWidth = 100;
vb.percentWidth = 100;
vb.paddingBottom = 5;
vb.paddingLeft = 5;
vb.paddingRight = 5;
vb.paddingTop = 5;
vb.addElement(label);
vb.addElement(this.textInput);
this.fileSysTree.extensions = extArray;
this.fileSysTree.showExtensions = true;
this.fileSysTree.showIcons = true;
this.fileSysTree.showHidden = false;
this.fileSysTree.height = 200;
this.fileSysTree.percentWidth = 100;
this.fileSysTree.addEventListener(FileEvent.FILE_CHOOSE,fileChoosen);
vb.addElement(this.fileSysTree);
this.panel = new Panel();
this.panel.title = "Open File";
this.panel.width = 400;
this.panel.height = 340;
this.panel.addElement(vb);
this.panel.controlBarContent = cb;
var hAlign:HorizontalLayout = new HorizontalLayout;
hAlign.horizontalAlign = "right";
hAlign.paddingLeft = 5;
hAlign.paddingRight = 5;
hAlign.paddingTop = 5;
hAlign.paddingBottom = 5;
this.panel.controlBarLayout = hAlign;
}
/**
* @private
* Update the text field to represent the selected file
*
* @param evt The FILE_CHOOSE event from the file system tree
*/
private function fileChoosen(evt:FileEvent):void {
this.fileLocation = evt.file.nativePath;
this.textInput.text = this.fileLocation;
closeAndSave(null);
}
/**
* @private
* Close the panel and return the PopUpReturnEvent
*
* @param evt The click event from the Fetch Button
*/
private function closeAndSave(evt:Event):void {
this.fileLocation = this.textInput.text;
PopUpManager.removePopUp(panel);
var newEvent:PopUpReturnEvent = new PopUpReturnEvent(PopUpReturnEvent.FILE_RETURNED,true);
dispatchEvent(newEvent);
}
/**
* @private
* Close the PopUp because the user clicked cancel.
*/
private function closePopUp(evt:Event):void {
PopUpManager.removePopUp(panel);
}
/**
* Create the PopUp panel and center it.
*
* @param myD The DisplayObject to display the PopUp within
*/
public function createPopUp(myD:DisplayObject):void {
PopUpManager.addPopUp(this.panel, myD, true);
PopUpManager.centerPopUp(this.panel);
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.