Menu

[r5]: / trunk / dumpLSO / src / dumpLSO.mxml  Maximize  Restore  History

Download this file

203 lines (172 with data), 7.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
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
<?xml version="1.0" encoding="utf-8"?>
<s:Application 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="352" height="585" backgroundColor="#60f3ea">
<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 mx.collections.ArrayCollection;
//import mx.controls.Alert;
//import mx.utils.ObjectUtil;
import flash.utils.describeType;
import ParamHandlers.ObjectParser;
[Bindable]
private var varTypes:ArrayCollection = new ArrayCollection(
[ {label:"String", data:"String"},
{label:"int", data:"int"},
{label:"Array", data:"Array"},
{label:"Number", data:"Number"},
{label:"Boolean", data:"Boolean"},
{label:"uint", data:"uint"},
{label:"XML", data:"XML"},
{label:"null", data:"null"} ]);
[Bindable]
private var amfTypes:ArrayCollection = new ArrayCollection(
[ {label:"AMF3", data:"AMF3"},
{label:"AMF0", data:"AMF0"} ]);
private var currentLSO:SharedObject;
private var lsoInfo:Object = new Object;
/**
* @private
* This will update the LSO based on the information entered into the text fields.
*/
private function updateLSO():void {
var data:*;
var type:String = this.sType1.selectedItem.data;
switch (type) {
case "int":
data = int(this.lsoValue.text);
break;
case "Array":
data = this.lsoValue.text.split(",");
break;
case "null":
data = null;
break;
case "Number":
data = Number(this.lsoValue.text);
break;
case "XML":
data = new XML(this.lsoValue.text);
break;
case "uint":
data = uint(Number(this.lsoValue.text));
break;
case "Boolean":
if (this.lsoValue.text == "true" || this.lsoValue.text == "1") {
data = true;
} else {
data = false;
}
break;
default:
data = this.lsoValue.text;
}
var tArray:Array = this.lsoName.text.split(".");
var dArray:Array = new Array();
var dFlag:int = -1;
if (this.amfVersion.selectedItem.data == "AMF0") {
this.currentLSO.objectEncoding = ObjectEncoding.AMF0;
} else {
this.currentLSO.objectEncoding = ObjectEncoding.AMF3;
}
for each (var name:* in tArray) {
if (dFlag == -1 && tArray.length == 1) {
currentLSO.data[name] = data;
} else if (tArray.length == dFlag + 2) {
dArray[dFlag][name] = data;
} else if (dFlag == -1) {
dArray.push(currentLSO.data[name]);
} else {
dArray.push(dArray[dFlag][name]);
}
dFlag++;
}
this.currentLSO.flush();
getInfo(true);
}
/**
* @private
* Retrieve the info for the local shared object. This is launched by setTimeout or manually.
*
* @param manual Boolean determining it is a manual refresh of the data (default false).
*/
private function getInfo(manual:Boolean = false):void {
var mySO:SharedObject;
var outputData:String = "";
var conn:LocalConnection = new LocalConnection;
if (!manual) {
this.lsoInfo.lsoName = "";
this.lsoInfo.lsoPath = "";
this.lsoInfo.lsoSecure = "";
try {
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
this.lsoInfo.lsoName = String(paramObj["lsoName"]);
if (paramObj["lsoPath"] != null) {
this.lsoInfo.lsoPath = String(paramObj["lsoPath"]);
}
if (paramObj["lsoSecure"] != null) {
this.lsoInfo.lsoSecure = String(paramObj["lsoSecure"]);
}
} catch (error:Error) {
//trace(error);
}
}
displayTest.text = "lsoName: " + this.lsoInfo.lsoName + "\r" + "Domain: " + conn.domain.toString() + "\r";
var lSecure:Boolean = false;
if (this.lsoInfo.lsoSecure.indexOf("true") == 0) {
lSecure = true;
}
displayTest.text += "Secure: " + this.lsoInfo.lsoSecure + "\r";
if (this.lsoInfo.lsoPath != null && this.lsoInfo.lsoPath.length > 0) {
displayTest.text += "lsoPath: " + this.lsoInfo.lsoPath + "\r";
try {
mySO = SharedObject.getLocal(this.lsoInfo.lsoName,this.lsoInfo.lsoPath,lSecure);
} catch (error:Error) {
//Typically thrown if "Allow third party content to store data on your computer" is
//not set within the Flash settings manager.
displayTest.text += error.toString() + "\r\r";
}
} else {
displayTest.text += "lsoPath: default\r";
try {
mySO = SharedObject.getLocal(this.lsoInfo.lsoName,null,lSecure);
} catch (error:Error) {
//Typically thrown if "Allow third party content to store data on your computer" is
//not set within the Flash settings manager.
displayTest.text += error.toString() + "\r\r";
}
}
this.currentLSO = mySO;
//displayTest.text += "Object Encoding: " + mySO.objectEncoding.toString() + "\r";
displayTest.text += "---------------------\r\r";
var oParser:ObjectParser = new ObjectParser();
if (mySO != null && mySO.data && mySO.data != null) {
//outputData += ObjectUtil.toString(mySO.data);
outputData += oParser.arrayToString(mySO.data);
} else {
outputData += "Could not retrieve data";
}
displayTest.text = displayTest.text + outputData;
}
private var intervalId:uint = setTimeout(getInfo,500);
]]>
</fx:Script>
<s:Label x="10" y="10" text="Name"/>
<s:TextInput x="55" y="8" id="lsoName" width="287"/>
<s:Label x="10" y="36" text="Value"/>
<s:TextInput x="54" y="34" id="lsoValue" width="287"/>
<s:DropDownList x="51" y="64" width="104" dataProvider="{this.varTypes}" id="sType1"/>
<s:Button x="267" y="97" label="update" click="updateLSO()"/>
<s:TextArea x="5" y="125" width="342" height="450" id="displayTest" editable="true" enabled="true" lineBreak="toFit" text="Testing..."/>
<s:Label x="173" y="66" width="92" text="AMF Encoding:"/>
<s:DropDownList x="263" y="64" width="79" id="amfVersion" enabled="true" dataProvider="{this.amfTypes}"/>
<s:Label x="10" y="66" text="Type"/>
</s:Application>
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.