Permalink
Browse files

3.2 Beta 1 for AS3 on Flex 4.6

  • Loading branch information...
1 parent 2b5d770 commit a39e3286c68ccd20315df3f252d69e857456ce3b geremy cohen committed Aug 4, 2012
Showing with 26,594 additions and 0 deletions.
  1. 0 flash/{ → AS3_Flex_4.6}/MessageBox.as
  2. +704 −0 flash/AS3_Flex_4.6/PubNub/PubNub.as
  3. +39 −0 flash/AS3_Flex_4.6/PubNub/PubNubEvent.as
  4. +133 −0 flash/AS3_Flex_4.6/PubNub/PubnubCrypto.as
  5. +98 −0 flash/AS3_Flex_4.6/com/adobe/air/logging/FileTarget.as
  6. +127 −0 flash/AS3_Flex_4.6/com/adobe/crypto/HMAC.as
  7. +281 −0 flash/AS3_Flex_4.6/com/adobe/crypto/MD5.as
  8. +402 −0 flash/AS3_Flex_4.6/com/adobe/crypto/MD5Stream.as
  9. +271 −0 flash/AS3_Flex_4.6/com/adobe/crypto/SHA1.as
  10. +257 −0 flash/AS3_Flex_4.6/com/adobe/crypto/SHA224.as
  11. +261 −0 flash/AS3_Flex_4.6/com/adobe/crypto/SHA256.as
  12. +114 −0 flash/AS3_Flex_4.6/com/adobe/crypto/WSSEUsernameToken.as
  13. +63 −0 flash/AS3_Flex_4.6/com/adobe/errors/IllegalStateError.as
  14. +47 −0 flash/AS3_Flex_4.6/com/adobe/fileformats/vcard/Address.as
  15. +39 −0 flash/AS3_Flex_4.6/com/adobe/fileformats/vcard/Email.as
  16. +39 −0 flash/AS3_Flex_4.6/com/adobe/fileformats/vcard/Phone.as
  17. +54 −0 flash/AS3_Flex_4.6/com/adobe/fileformats/vcard/VCard.as
  18. +246 −0 flash/AS3_Flex_4.6/com/adobe/fileformats/vcard/VCardParser.as
  19. +39 −0 flash/AS3_Flex_4.6/com/adobe/images/BitString.as
  20. +648 −0 flash/AS3_Flex_4.6/com/adobe/images/JPGEncoder.as
  21. +141 −0 flash/AS3_Flex_4.6/com/adobe/images/PNGEncoder.as
  22. +55 −0 flash/AS3_Flex_4.6/com/adobe/net/DynamicURLLoader.as
  23. +76 −0 flash/AS3_Flex_4.6/com/adobe/net/IURIResolver.as
  24. +196 −0 flash/AS3_Flex_4.6/com/adobe/net/MimeTypeMap.as
  25. +2,466 −0 flash/AS3_Flex_4.6/com/adobe/net/URI.as
  26. +139 −0 flash/AS3_Flex_4.6/com/adobe/net/URIEncodingBitmap.as
  27. +198 −0 flash/AS3_Flex_4.6/com/adobe/net/proxies/RFC2817Socket.as
  28. +34 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/Database.as
  29. +39 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/Definition.as
  30. +328 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/Dict.as
  31. +28 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/DictionaryServer.as
  32. +34 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/MatchStrategy.as
  33. +39 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/Response.as
  34. +14 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/events/ConnectedEvent.as
  35. +26 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/events/DatabaseEvent.as
  36. +27 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/events/DefinitionEvent.as
  37. +26 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/events/DefinitionHeaderEvent.as
  38. +26 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/events/DictionaryServerEvent.as
  39. +14 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/events/DisconnectedEvent.as
  40. +37 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/events/ErrorEvent.as
  41. +26 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/events/MatchEvent.as
  42. +26 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/events/MatchStrategiesEvent.as
  43. +14 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/events/NoMatchEvent.as
  44. +25 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/util/CompleteResponseEvent.as
  45. +49 −0 flash/AS3_Flex_4.6/com/adobe/protocols/dict/util/SocketHelper.as
  46. +85 −0 flash/AS3_Flex_4.6/com/adobe/serialization/json/JSON.as
  47. +221 −0 flash/AS3_Flex_4.6/com/adobe/serialization/json/JSONDecoder.as
  48. +299 −0 flash/AS3_Flex_4.6/com/adobe/serialization/json/JSONEncoder.as
  49. +87 −0 flash/AS3_Flex_4.6/com/adobe/serialization/json/JSONParseError.as
  50. +104 −0 flash/AS3_Flex_4.6/com/adobe/serialization/json/JSONToken.as
  51. +67 −0 flash/AS3_Flex_4.6/com/adobe/serialization/json/JSONTokenType.as
  52. +583 −0 flash/AS3_Flex_4.6/com/adobe/serialization/json/JSONTokenizer.as
  53. +187 −0 flash/AS3_Flex_4.6/com/adobe/utils/ArrayUtil.as
  54. +699 −0 flash/AS3_Flex_4.6/com/adobe/utils/DateUtil.as
  55. +87 −0 flash/AS3_Flex_4.6/com/adobe/utils/DictionaryUtil.as
  56. +99 −0 flash/AS3_Flex_4.6/com/adobe/utils/IntUtil.as
  57. +74 −0 flash/AS3_Flex_4.6/com/adobe/utils/NumberFormatter.as
  58. +270 −0 flash/AS3_Flex_4.6/com/adobe/utils/StringUtil.as
  59. +168 −0 flash/AS3_Flex_4.6/com/adobe/utils/XMLUtil.as
  60. +48 −0 flash/AS3_Flex_4.6/com/adobe/webapis/ServiceBase.as
  61. +108 −0 flash/AS3_Flex_4.6/com/adobe/webapis/URLLoaderBase.as
  62. +75 −0 flash/AS3_Flex_4.6/com/adobe/webapis/events/ServiceEvent.as
  63. +273 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/Crypto.as
  64. +3,235 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/cert/MozillaRootCertificates.as
  65. +218 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/cert/X509Certificate.as
  66. +57 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/cert/X509CertificateCollection.as
  67. +82 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/hash/HMAC.as
  68. +20 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/hash/IHash.as
  69. +116 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/hash/MD2.as
  70. +196 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/hash/MD5.as
  71. +106 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/hash/SHA1.as
  72. +28 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/hash/SHA224.as
  73. +114 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/hash/SHA256.as
  74. +62 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/hash/SHABase.as
  75. +90 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/prng/ARC4.as
  76. +20 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/prng/IPRNG.as
  77. +119 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/prng/Random.as
  78. +142 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/prng/TLSPRF.as
  79. +319 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/rsa/RSAKey.as
  80. +477 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/AESKey.as
  81. +375 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/BlowFishKey.as
  82. +58 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/CBCMode.as
  83. +61 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/CFB8Mode.as
  84. +64 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/CFBMode.as
  85. +58 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/CTRMode.as
  86. +365 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/DESKey.as
  87. +86 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/ECBMode.as
  88. +21 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/ICipher.as
  89. +15 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/IMode.as
  90. +32 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/IPad.as
  91. +21 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/IStreamCipher.as
  92. +35 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/ISymmetricKey.as
  93. +114 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/IVMode.as
  94. +34 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/NullPad.as
  95. +52 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/OFBMode.as
  96. +47 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/PKCS5.as
  97. +60 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/SimpleIVMode.as
  98. +42 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/TLSPad.as
  99. +88 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/TripleDESKey.as
  100. +94 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/symmetric/XTeaKey.as
  101. +1,220 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/AESKeyTest.as
  102. +58 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/ARC4Test.as
  103. +39 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/BigIntegerTest.as
  104. +148 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/BlowFishKeyTest.as
  105. +160 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/CBCModeTest.as
  106. +71 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/CFB8ModeTest.as
  107. +98 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/CFBModeTest.as
  108. +109 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/CTRModeTest.as
  109. +112 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/DESKeyTest.as
  110. +151 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/ECBModeTest.as
  111. +184 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/HMACTest.as
  112. +20 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/ITestHarness.as
  113. +56 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/MD2Test.as
  114. +58 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/MD5Test.as
  115. +101 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/OFBModeTest.as
  116. +92 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/RSAKeyTest.as
  117. +198 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/SHA1Test.as
  118. +58 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/SHA224Test.as
  119. +60 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/SHA256Test.as
  120. +51 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/TLSPRFTest.as
  121. +42 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/TestCase.as
  122. +59 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/TripleDESKeyTest.as
  123. +66 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tests/XTeaKeyTest.as
  124. +97 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/BulkCiphers.as
  125. +117 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/CipherSuites.as
  126. +24 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/KeyExchanges.as
  127. +27 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/MACs.as
  128. +60 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/TLSConfig.as
  129. +148 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/TLSConnectionState.as
  130. +728 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/TLSEngine.as
  131. +39 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/TLSError.as
  132. +26 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/TLSEvent.as
  133. +150 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/TLSSecurityParameters.as
  134. +294 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/TLSSocket.as
  135. +123 −0 flash/AS3_Flex_4.6/com/hurlant/crypto/tls/TLSTest.as
  136. +90 −0 flash/AS3_Flex_4.6/com/hurlant/math/BarrettReduction.as
  137. +1,526 −0 flash/AS3_Flex_4.6/com/hurlant/math/BigInteger.as
  138. +35 −0 flash/AS3_Flex_4.6/com/hurlant/math/ClassicReduction.as
  139. +11 −0 flash/AS3_Flex_4.6/com/hurlant/math/IReduction.as
  140. +85 −0 flash/AS3_Flex_4.6/com/hurlant/math/MontgomeryReduction.as
  141. +34 −0 flash/AS3_Flex_4.6/com/hurlant/math/NullReduction.as
  142. +11 −0 flash/AS3_Flex_4.6/com/hurlant/math/bi_internal.as
  143. +25 −0 flash/AS3_Flex_4.6/com/hurlant/util/ArrayUtil.as
  144. +134 −0 flash/AS3_Flex_4.6/com/hurlant/util/Base64.as
  145. +66 −0 flash/AS3_Flex_4.6/com/hurlant/util/Hex.as
  146. +28 −0 flash/AS3_Flex_4.6/com/hurlant/util/Memory.as
  147. +43 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/ByteString.as
  148. +210 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/DER.as
  149. +21 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/IAsn1Type.as
  150. +44 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/Integer.as
  151. +35 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/OID.as
  152. +112 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/ObjectIdentifier.as
  153. +118 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/PEM.as
  154. +49 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/PrintableString.as
  155. +90 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/Sequence.as
  156. +27 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/Set.as
  157. +94 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/Type.as
  158. +60 −0 flash/AS3_Flex_4.6/com/hurlant/util/der/UTCTime.as
  159. BIN flash/MessageBox.swf
File renamed without changes.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,39 @@
+package PubNub
+{
+ import flash.events.Event;
+
+ /**
+ * Pub Nub Event
+ * @author Fan Di
+ */
+ public class PubNubEvent extends Event
+ {
+ public static const SUBSCRIBE_CONNECTED:String = "SubscribeConnected";
+ public static const PUBLISH:String = "Publish";
+ public static const SUBSCRIBE:String = "Subscribe";
+ public static const PRESENCE:String = "Presence";
+ public static const HERE_NOW:String = "HereNow";
+ public static const HISTORY:String = "History";
+ public static const TIME:String="Time";
+ public static const UNSUBSCRIBE:String = "Unsubscribe";
+ public static const ERROR:String = "Error";
+ public static const INIT:String = "Init";
+ public var data:Object;
+
+ public function PubNubEvent(type:String, d:Object = null, bubbles:Boolean=false, cancelable:Boolean=false)
+ {
+ data = d;
+ super(type, bubbles, cancelable);
+ }
+
+ public override function clone():Event
+ {
+ return new PubNubEvent(type, data, bubbles, cancelable);
+ }
+
+ public override function toString():String
+ {
+ return formatToString("PubNubEvent", "type", "bubbles", "cancelable", "eventPhase");
+ }
+ }
+}
@@ -0,0 +1,133 @@
+package PubNub
+{
+ import com.adobe.crypto.MD5;
+ import com.adobe.utils.IntUtil;
+ import com.hurlant.crypto.Crypto;
+ import com.hurlant.crypto.symmetric.AESKey;
+ import com.hurlant.crypto.symmetric.CBCMode;
+ import com.hurlant.crypto.symmetric.ICipher;
+ import com.hurlant.crypto.symmetric.IMode;
+ import com.hurlant.crypto.symmetric.IPad;
+ import com.hurlant.crypto.symmetric.IVMode;
+ import com.hurlant.crypto.symmetric.NullPad;
+ import com.hurlant.crypto.symmetric.PKCS5;
+ import com.hurlant.util.Base64;
+ import com.hurlant.util.Hex;
+
+ import flash.display.Sprite;
+ import flash.utils.ByteArray;
+
+ public class PubnubCrypto extends Sprite
+ {
+ private var type:String='aes-cbc';
+
+ //Basic encryption for string
+ public function encryptString(cipher_key:String, plainStr:String ):String
+ {
+ cipher_key = md5Key(cipher_key);
+ var key:ByteArray = Hex.toArray(cipher_key);
+ var data:ByteArray = Hex.toArray(Hex.fromString(plainStr));
+ var cbc:CBCMode = new CBCMode(new AESKey(key),new PKCS5());
+ cbc.IV = Hex.toArray(Hex.fromString("0123456789012345"));
+ cbc.encrypt(data);
+ return Base64.encodeByteArray(data);
+ }
+
+ //Basic decryption for string
+ public function decryptString(cipher_key:String, cipherStr:String):String
+ {
+ var data:ByteArray = Base64.decodeToByteArray(cipherStr);
+ cipher_key = md5Key(cipher_key);
+ var key:ByteArray = Hex.toArray(cipher_key);
+ var testkey:ByteArray = new ByteArray;
+ var cbc:CBCMode = new CBCMode(new AESKey(key), new PKCS5());
+ cbc.IV = Hex.toArray(Hex.fromString("0123456789012345"));
+ cbc.decrypt(data);
+ return Hex.toString(Hex.fromArray(data));
+ }
+
+ //Encryption for string/object/array
+ public function encrypt(cipher_key:String, plainObj:* ):*
+ {
+ if(typeof(plainObj) == "object")
+ {
+ if(plainObj.length == undefined) //plainObj is object
+ {
+ var cipherObj:Object = new Object();
+ for(var s:String in plainObj)
+ {
+ if(typeof(plainObj[s]) == "object")
+ {
+ cipherObj[s] = encrypt(cipher_key,plainObj[s]);
+ }
+ else
+ {
+ cipherObj[s] = encryptString(cipher_key,plainObj[s]);
+ }
+ }
+ return cipherObj;
+ }
+ else
+ {
+ //plainObj is array
+ var cipherArray:Array = new Array();
+ for(var i:int =0;i<plainObj.length;i++)
+ {
+ cipherArray[i] = encryptString(cipher_key,plainObj[i])
+ }
+ return cipherArray;
+ }
+ }
+ else if(typeof(plainObj) == "string")
+ {
+ return encryptString(cipher_key,plainObj);
+ }
+ }
+
+ //Decryption for string/object/array
+ public function decrypt(cipher_key:String, cipherObj:* ):*
+ {
+ if(typeof(cipherObj) == "object")
+ {
+ if(cipherObj.length == undefined) //cipherObj is object
+ {
+ var plainObj:Object = new Object();
+ for(var s:String in cipherObj)
+ {
+ if(typeof(cipherObj[s]) == "object")
+ {
+ plainObj[s] = decrypt(cipher_key,cipherObj[s]);
+ plainObj[s] = JSON.parse(plainObj[s].toString());
+ }
+ else
+ {
+ plainObj[s] = decryptString(cipher_key,cipherObj[s]);
+ }
+ }
+ return JSON.stringify(plainObj);
+ }
+ else
+ {
+ //cipherObj is array
+ var plainArray:Array = new Array();
+ for(var i:int =0;i<cipherObj.length;i++)
+ {
+ plainArray[i] = decryptString(cipher_key,cipherObj[i])
+ }
+ return JSON.stringify(plainArray);
+ }
+ }
+ else if(typeof(cipherObj) =="string")
+ {
+ return JSON.stringify(decryptString(cipher_key,cipherObj));
+ }
+ }
+
+ public function md5Key(s:String) :String
+ {
+ var ba:ByteArray = new ByteArray();
+ ba.writeUTFBytes(s);
+ return MD5.hashBinary(ba);
+ }
+ }
+}
@@ -0,0 +1,98 @@
+/*
+ Copyright (c) 2008, Adobe Systems Incorporated
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package com.adobe.air.logging
+{
+ import mx.logging.AbstractTarget;
+ import flash.filesystem.File;
+ import flash.filesystem.FileStream;
+ import flash.filesystem.FileMode;
+ import mx.logging.LogEvent;
+ import flash.system.System;
+ import flash.system.Capabilities;
+ import mx.logging.targets.LineFormattedTarget;
+ import mx.core.mx_internal;
+
+ use namespace mx_internal;
+
+ /**
+ * An Adobe AIR only class that provides a log target for the Flex logging
+ * framework, that logs files to a file on the user's system.
+ *
+ * This class will only work when running within Adobe AIR>
+ */
+ public class FileTarget extends LineFormattedTarget
+ {
+ private const DEFAULT_LOG_PATH:String = "app-storage:/application.log";
+
+ private var log:File;
+
+ public function FileTarget(logFile:File = null)
+ {
+ if(logFile != null)
+ {
+ log = logFile;
+ }
+ else
+ {
+ log = new File(DEFAULT_LOG_PATH);
+ }
+ }
+
+ public function get logURI():String
+ {
+ return log.url;
+ }
+
+ mx_internal override function internalLog(message:String):void
+ {
+ write(message);
+ }
+
+ private function write(msg:String):void
+ {
+ var fs:FileStream = new FileStream();
+ fs.open(log, FileMode.APPEND);
+ fs.writeUTFBytes(msg + "\n");
+ fs.close();
+ }
+
+ public function clear():void
+ {
+ var fs:FileStream = new FileStream();
+ fs.open(log, FileMode.WRITE);
+ fs.writeUTFBytes("");
+ fs.close();
+ }
+
+ }
+}
Oops, something went wrong.

0 comments on commit a39e328

Please sign in to comment.