Menu

[r11]: / trunk / SWFInvestigator / src / lsoViewer / LSOTab.mxml  Maximize  Restore  History

Download this file

219 lines (188 with data), 8.2 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?xml version="1.0" encoding="utf-8"?>
<s:NavigatorContent xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="739" height="631">
<fx:Script>
<![CDATA[
/****************************************************************************
* 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.
* ****************************************************************************/
import lsoViewer.LSOInfo;
import mx.events.FileEvent;
private var LSODirPath:String;
private var currentLSO:LSOInfo = new LSOInfo();
private var domain:String;
/**
* This function is called when SWF Investigator closes to remove any left over temp files
*/
public function onClose(): void {
if (currentLSO.swfName.indexOf("None") != 0) {
var sourceFile:File = File.applicationStorageDirectory;
sourceFile = sourceFile.resolvePath("lsoViewer/" + currentLSO.swfName);
if (sourceFile.exists) {
sourceFile.deleteFile();
}
}
}
/**
* @private
* Set the directory where the LSO's live for the File Chooser
*/
private function setDirectory():void {
var LSOPath:String;
this.warningText.text = "";
if (Capabilities.os.indexOf("Windows Vista") == 0) {
LSOPath = "./AppData/Roaming/Macromedia/Flash Player/#SharedObjects/";
} else if (Capabilities.os.indexOf("Windows") == 0) {
LSOPath = "./Applic~1/Macromedia/Flash Player/#SharedObjects/";
} else if (Capabilities.os.indexOf("Mac OS 10") == 0) {
LSOPath = "./Library/Preferences/Macromedia/Flash Player/#SharedObjects/"
} else {
LSOPath = "./.macromedia/Flash_Player/#SharedObjects/";
}
var LSODir:File = File.userDirectory.resolvePath(LSOPath);
//This handles the random directory
var fileArray:Array = LSODir.getDirectoryListing();
LSODirPath = fileArray[0].nativePath;
FST.directory = new File(LSODirPath);
FST.directory.addEventListener(FileListEvent.DIRECTORY_LISTING, checkDirLength);
FST.directory.getDirectoryListingAsync();
FST.addEventListener(FileEvent.FILE_CHOOSE,selectedFile);
}
/**
* @private
* This function just sets the warningText if no directories are available
*
* @param e The FileListEvent from the FST.directory
*/
private function checkDirLength(e:FileListEvent):void {
if (e.files != null && e.files.length == 0) {
this.warningText.setStyle("color",0xFF0000);
this.warningText.text = "No LSOs found!";
this.FST.enabled = false;
this.hLoader.enabled = false;
}
}
/**
* @private
* Set the directory to the domain of the SWF
*
* @param domain The domain to change focus to in the File Chooser.
*/
private function changeFocus(domain:String):void {
if (domain == null) {
return;
}
var focusPath:String = FST.directory.nativePath;
if (Capabilities.os.indexOf("Windows") == 0) {
focusPath += "\\" + domain;
} else {
focusPath += "/" + domain;
}
if (this.FST.findItem(focusPath) != null) {
this.FST.selectedPath = focusPath;
var fIndex:int = this.FST.findIndex(focusPath);
this.FST.scrollToIndex(fIndex);
this.FST.openSubdirectory(focusPath);
}
}
/**
* @private
* Once a file is selected, this will parse the path to determine the original web path.
*
* @param e The FileEvent from the selection of the file.
*/
private function selectedFile(e:FileEvent):void {
currentLSO.clear();
var chosenFile:String = e.currentTarget.selectedPath;
//var debugInfo:String = "Native path: " + chosenFile + "<br>";
var dirData:Array;
var pathInfo:String = chosenFile.substring (LSODirPath.length);
//debugInfo += "PathInfo: " + pathInfo + "<br>";
if (Capabilities.os.indexOf("Windows") == 0) {
currentLSO.dirInfo = pathInfo.substring(0,pathInfo.lastIndexOf("\\") + 1);
dirData = pathInfo.split("\\");
} else {
currentLSO.dirInfo = pathInfo.substring(0,pathInfo.lastIndexOf("/") + 1);
dirData = pathInfo.split("/");
}
//debugInfo += "dirInfo: " + currentLSO.dirInfo + "<br>";
currentLSO.LSOname = dirData[dirData.length - 1].toString();
if (currentLSO.LSOname.indexOf(".ssl") == currentLSO.LSOname.length - 4) {
currentLSO.secure = true;
//debugInfo += "Secure: " + currentLSO.secure + "<br>";
}
currentLSO.LSOname = currentLSO.LSOname.substring(0,currentLSO.LSOname.length-4);
//debugInfo += "LSOName: " + currentLSO.LSOname + "<br>";
var tempName:String = dirData[dirData.length - 2].toString();
if (tempName.length >= 4 && tempName.indexOf(".swf") == tempName.length - 4) {
currentLSO.swfName = tempName;
}
//debugInfo += "swfName: " + currentLSO.swfName + "<br>";
currentLSO.domain = dirData[1].toString();
//debugInfo += "domainName: " + currentLSO.domain + "<br>";
if (currentLSO.domain.indexOf("localhost") == 0) {
currentLSO.local = true;
}
//debugInfo += "webPath: " + currentLSO.getWebPath() + "<br>";
//displayDebug.htmlText = debugInfo;
setUpHTML();
}
/**
* @private
* Called after the sandbox mapper is loaded, this will set the JS variables
*/
private function setBridge (e:Event):void {
if (e.currentTarget.window.swfData != null) {
e.currentTarget.window.swfData.LSOName = currentLSO.LSOname;
e.currentTarget.window.swfData.SWFLocation = currentLSO.getSWFLocation();
e.currentTarget.window.swfData.sandboxRoot = currentLSO.getLSOURL();
e.currentTarget.window.swfData.documentRoot = currentLSO.getDocumentRoot();
e.currentTarget.window.swfData.removeFile = currentLSO.swfName;
e.currentTarget.window.writeLSOMap();
}
}
/**
* @private
* This loads the sandbox remapper into the HTML Loader
*/
private function setUpHTML():void {
hLoader.horizontalScrollPolicy="off";
hLoader.verticalScrollPolicy="off";
hLoader.htmlLoader.addEventListener(Event.COMPLETE,setBridge);
hLoader.htmlLoader.load(new URLRequest("app:/lsoViewer/sandboxRemapper.html"));
}
/**
* This function is used to set the domain folder that LSO Explorer should open by default
*
* @param sURL The URL of the SWF
*/
public function setDomain(sURL:String):void {
var pattern:RegExp = new RegExp("^http[s]?\:\\/\\/([^\\/]+)\\/");
var result:Object = pattern.exec(sURL);
if (result == null) {
if (sURL.indexOf("file:") == 0) {
this.domain = "#localWithNet";
} else {
mx.controls.Alert("Error Parsing URL");
return;
}
} else {
this.domain = result[1];
}
}
]]>
</fx:Script>
<s:Group>
<s:Label x="14" y="19" text="Select LSO file"/>
<s:Label id="warningText" x="201" y="19" width="109" text=""/>
<mx:FileSystemTree width="310" height="575" id="FST" enabled="true" showIcons="true" showExtensions="true" initialize="setDirectory()" x="10" creationComplete="changeFocus(this.domain)" y="36"/>
<s:Label x="375" y="19" text="Edit LSO"/>
<mx:HTML y="36" width="354" height="574" id="hLoader" x="369" borderStyle="solid"/>
</s:Group>
</s:NavigatorContent>
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.