diff --git a/README b/README old mode 100644 new mode 100755 index 5467989..85e3ecf --- a/README +++ b/README @@ -1,7 +1,7 @@ -Flex Pilot - -A library for doing easy testing automation of Flash and Flex -applications. Includes a locator/lookup mechanism, eventing, -and an AS3 test-runner. - - +Flex Pilot + +A library for doing easy testing automation of Flash and Flex +applications. Includes a locator/lookup mechanism, eventing, +and an AS3 test-runner. + + diff --git a/build.py b/build.py index dff3cec..847167b 100755 --- a/build.py +++ b/build.py @@ -6,7 +6,7 @@ import shutil # Location of compiler -MXMLC_PATH = 'mxmlc -debug -verbose-stacktraces -incremental=true -compiler.strict -compiler.show-actionscript-warnings -static-link-runtime-shared-libraries=true' +MXMLC_PATH = 'mxmlc -debug -verbose-stacktraces -incremental=true -compiler.strict -compiler.show-actionscript-warnings -static-link-runtime-shared-libraries=true -define=FP::complete,false' # For replacing .as with .swf as_re = re.compile('\.as$|\.mxml$') diff --git a/pkg/build.json b/pkg/build.json old mode 100644 new mode 100755 index ec9d78b..9e4e809 --- a/pkg/build.json +++ b/pkg/build.json @@ -1,22 +1,22 @@ -{ - "source-path": - ".", - "output": - "flex_pilot.swc", - "include-classes": - [ - "org.flex_pilot.FlexPilot", - "org.flex_pilot.FPController", - "org.flex_pilot.FPLocator", - "org.flex_pilot.FPLogger", - "org.flex_pilot.FPExplorer", - "org.flex_pilot.FPRecorder", - "org.flex_pilot.FPAssert", - "org.flex_pilot.events.Events", - "org.flex_pilot.events.FPFocusEvent", - "org.flex_pilot.events.FPKeyboardEvent", - "org.flex_pilot.events.FPListEvent", - "org.flex_pilot.events.FPMouseEvent", - "org.flex_pilot.events.FPTextEvent" - ] -} +{ + "source-path": + ".", + "output": + "flex_pilot.swc", + "include-classes": + [ + "org.flex_pilot.FlexPilot", + "org.flex_pilot.FPController", + "org.flex_pilot.FPLocator", + "org.flex_pilot.FPLogger", + "org.flex_pilot.FPExplorer", + "org.flex_pilot.FPRecorder", + "org.flex_pilot.FPAssert", + "org.flex_pilot.events.Events", + "org.flex_pilot.events.FPFocusEvent", + "org.flex_pilot.events.FPKeyboardEvent", + "org.flex_pilot.events.FPListEvent", + "org.flex_pilot.events.FPMouseEvent", + "org.flex_pilot.events.FPTextEvent" + ] +} diff --git a/src/com/adobe/air/logging/FileTarget.as b/src/com/adobe/air/logging/FileTarget.as old mode 100644 new mode 100755 index 0dda3eb..02e3871 --- a/src/com/adobe/air/logging/FileTarget.as +++ b/src/com/adobe/air/logging/FileTarget.as @@ -1,98 +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(); - } - - } +/* + 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(); + } + + } } \ No newline at end of file diff --git a/src/com/adobe/crypto/HMAC.as b/src/com/adobe/crypto/HMAC.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/crypto/MD5.as b/src/com/adobe/crypto/MD5.as old mode 100644 new mode 100755 index da533cc..53407b1 --- a/src/com/adobe/crypto/MD5.as +++ b/src/com/adobe/crypto/MD5.as @@ -1,281 +1,281 @@ -/* - 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.crypto { - - import com.adobe.utils.IntUtil; - import flash.utils.ByteArray; - /** - * The MD5 Message-Digest Algorithm - * - * Implementation based on algorithm description at - * http://www.faqs.org/rfcs/rfc1321.html - */ - public class MD5 { - - public static var digest:ByteArray; - /** - * Performs the MD5 hash algorithm on a string. - * - * @param s The string to hash - * @return A string containing the hash value of s - * @langversion ActionScript 3.0 - * @playerversion Flash 8.5 - * @tiptext - */ - - public static function hash(s:String) :String{ - //Convert to byteArray and send through hashBinary function - // so as to only have complex code in one location - var ba:ByteArray = new ByteArray(); - ba.writeUTFBytes(s); - return hashBinary(ba); - } - - public static function hashBytes(s:ByteArray) :String{ - return hashBinary(s); - } - - /** - * Performs the MD5 hash algorithm on a ByteArray. - * - * @param s The string to hash - * @return A string containing the hash value of s - * @langversion ActionScript 3.0 - * @playerversion Flash 8.5 - * @tiptext - */ - public static function hashBinary( s:ByteArray ):String { - // initialize the md buffers - var a:int = 1732584193; - var b:int = -271733879; - var c:int = -1732584194; - var d:int = 271733878; - - // variables to store previous values - var aa:int; - var bb:int; - var cc:int; - var dd:int; - - // create the blocks from the string and - // save the length as a local var to reduce - // lookup in the loop below - var x:Array = createBlocks( s ); - var len:int = x.length; - - // loop over all of the blocks - for ( var i:int = 0; i < len; i += 16) { - // save previous values - aa = a; - bb = b; - cc = c; - dd = d; - - // Round 1 - a = ff( a, b, c, d, x[int(i+ 0)], 7, -680876936 ); // 1 - d = ff( d, a, b, c, x[int(i+ 1)], 12, -389564586 ); // 2 - c = ff( c, d, a, b, x[int(i+ 2)], 17, 606105819 ); // 3 - b = ff( b, c, d, a, x[int(i+ 3)], 22, -1044525330 ); // 4 - a = ff( a, b, c, d, x[int(i+ 4)], 7, -176418897 ); // 5 - d = ff( d, a, b, c, x[int(i+ 5)], 12, 1200080426 ); // 6 - c = ff( c, d, a, b, x[int(i+ 6)], 17, -1473231341 ); // 7 - b = ff( b, c, d, a, x[int(i+ 7)], 22, -45705983 ); // 8 - a = ff( a, b, c, d, x[int(i+ 8)], 7, 1770035416 ); // 9 - d = ff( d, a, b, c, x[int(i+ 9)], 12, -1958414417 ); // 10 - c = ff( c, d, a, b, x[int(i+10)], 17, -42063 ); // 11 - b = ff( b, c, d, a, x[int(i+11)], 22, -1990404162 ); // 12 - a = ff( a, b, c, d, x[int(i+12)], 7, 1804603682 ); // 13 - d = ff( d, a, b, c, x[int(i+13)], 12, -40341101 ); // 14 - c = ff( c, d, a, b, x[int(i+14)], 17, -1502002290 ); // 15 - b = ff( b, c, d, a, x[int(i+15)], 22, 1236535329 ); // 16 - - // Round 2 - a = gg( a, b, c, d, x[int(i+ 1)], 5, -165796510 ); // 17 - d = gg( d, a, b, c, x[int(i+ 6)], 9, -1069501632 ); // 18 - c = gg( c, d, a, b, x[int(i+11)], 14, 643717713 ); // 19 - b = gg( b, c, d, a, x[int(i+ 0)], 20, -373897302 ); // 20 - a = gg( a, b, c, d, x[int(i+ 5)], 5, -701558691 ); // 21 - d = gg( d, a, b, c, x[int(i+10)], 9, 38016083 ); // 22 - c = gg( c, d, a, b, x[int(i+15)], 14, -660478335 ); // 23 - b = gg( b, c, d, a, x[int(i+ 4)], 20, -405537848 ); // 24 - a = gg( a, b, c, d, x[int(i+ 9)], 5, 568446438 ); // 25 - d = gg( d, a, b, c, x[int(i+14)], 9, -1019803690 ); // 26 - c = gg( c, d, a, b, x[int(i+ 3)], 14, -187363961 ); // 27 - b = gg( b, c, d, a, x[int(i+ 8)], 20, 1163531501 ); // 28 - a = gg( a, b, c, d, x[int(i+13)], 5, -1444681467 ); // 29 - d = gg( d, a, b, c, x[int(i+ 2)], 9, -51403784 ); // 30 - c = gg( c, d, a, b, x[int(i+ 7)], 14, 1735328473 ); // 31 - b = gg( b, c, d, a, x[int(i+12)], 20, -1926607734 ); // 32 - - // Round 3 - a = hh( a, b, c, d, x[int(i+ 5)], 4, -378558 ); // 33 - d = hh( d, a, b, c, x[int(i+ 8)], 11, -2022574463 ); // 34 - c = hh( c, d, a, b, x[int(i+11)], 16, 1839030562 ); // 35 - b = hh( b, c, d, a, x[int(i+14)], 23, -35309556 ); // 36 - a = hh( a, b, c, d, x[int(i+ 1)], 4, -1530992060 ); // 37 - d = hh( d, a, b, c, x[int(i+ 4)], 11, 1272893353 ); // 38 - c = hh( c, d, a, b, x[int(i+ 7)], 16, -155497632 ); // 39 - b = hh( b, c, d, a, x[int(i+10)], 23, -1094730640 ); // 40 - a = hh( a, b, c, d, x[int(i+13)], 4, 681279174 ); // 41 - d = hh( d, a, b, c, x[int(i+ 0)], 11, -358537222 ); // 42 - c = hh( c, d, a, b, x[int(i+ 3)], 16, -722521979 ); // 43 - b = hh( b, c, d, a, x[int(i+ 6)], 23, 76029189 ); // 44 - a = hh( a, b, c, d, x[int(i+ 9)], 4, -640364487 ); // 45 - d = hh( d, a, b, c, x[int(i+12)], 11, -421815835 ); // 46 - c = hh( c, d, a, b, x[int(i+15)], 16, 530742520 ); // 47 - b = hh( b, c, d, a, x[int(i+ 2)], 23, -995338651 ); // 48 - - // Round 4 - a = ii( a, b, c, d, x[int(i+ 0)], 6, -198630844 ); // 49 - d = ii( d, a, b, c, x[int(i+ 7)], 10, 1126891415 ); // 50 - c = ii( c, d, a, b, x[int(i+14)], 15, -1416354905 ); // 51 - b = ii( b, c, d, a, x[int(i+ 5)], 21, -57434055 ); // 52 - a = ii( a, b, c, d, x[int(i+12)], 6, 1700485571 ); // 53 - d = ii( d, a, b, c, x[int(i+ 3)], 10, -1894986606 ); // 54 - c = ii( c, d, a, b, x[int(i+10)], 15, -1051523 ); // 55 - b = ii( b, c, d, a, x[int(i+ 1)], 21, -2054922799 ); // 56 - a = ii( a, b, c, d, x[int(i+ 8)], 6, 1873313359 ); // 57 - d = ii( d, a, b, c, x[int(i+15)], 10, -30611744 ); // 58 - c = ii( c, d, a, b, x[int(i+ 6)], 15, -1560198380 ); // 59 - b = ii( b, c, d, a, x[int(i+13)], 21, 1309151649 ); // 60 - a = ii( a, b, c, d, x[int(i+ 4)], 6, -145523070 ); // 61 - d = ii( d, a, b, c, x[int(i+11)], 10, -1120210379 ); // 62 - c = ii( c, d, a, b, x[int(i+ 2)], 15, 718787259 ); // 63 - b = ii( b, c, d, a, x[int(i+ 9)], 21, -343485551 ); // 64 - - a += aa; - b += bb; - c += cc; - d += dd; - } - digest = new ByteArray() - digest.writeInt(a); - digest.writeInt(b); - digest.writeInt(c); - digest.writeInt(d); - digest.position = 0; - // Finish up by concatening the buffers with their hex output - return IntUtil.toHex( a ) + IntUtil.toHex( b ) + IntUtil.toHex( c ) + IntUtil.toHex( d ); - } - - /** - * Auxiliary function f as defined in RFC - */ - private static function f( x:int, y:int, z:int ):int { - return ( x & y ) | ( (~x) & z ); - } - - /** - * Auxiliary function g as defined in RFC - */ - private static function g( x:int, y:int, z:int ):int { - return ( x & z ) | ( y & (~z) ); - } - - /** - * Auxiliary function h as defined in RFC - */ - private static function h( x:int, y:int, z:int ):int { - return x ^ y ^ z; - } - - /** - * Auxiliary function i as defined in RFC - */ - private static function i( x:int, y:int, z:int ):int { - return y ^ ( x | (~z) ); - } - - /** - * A generic transformation function. The logic of ff, gg, hh, and - * ii are all the same, minus the function used, so pull that logic - * out and simplify the method bodies for the transoformation functions. - */ - private static function transform( func:Function, a:int, b:int, c:int, d:int, x:int, s:int, t:int):int { - var tmp:int = a + int( func( b, c, d ) ) + x + t; - return IntUtil.rol( tmp, s ) + b; - } - - /** - * ff transformation function - */ - private static function ff ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { - return transform( f, a, b, c, d, x, s, t ); - } - - /** - * gg transformation function - */ - private static function gg ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { - return transform( g, a, b, c, d, x, s, t ); - } - - /** - * hh transformation function - */ - private static function hh ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { - return transform( h, a, b, c, d, x, s, t ); - } - - /** - * ii transformation function - */ - private static function ii ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { - return transform( i, a, b, c, d, x, s, t ); - } - - /** - * Converts a string to a sequence of 16-word blocks - * that we'll do the processing on. Appends padding - * and length in the process. - * - * @param s The string to split into blocks - * @return An array containing the blocks that s was - * split into. - */ - private static function createBlocks( s:ByteArray ):Array { - var blocks:Array = new Array(); - var len:int = s.length * 8; - var mask:int = 0xFF; // ignore hi byte of characters > 0xFF - for( var i:int = 0; i < len; i += 8 ) { - blocks[ int(i >> 5) ] |= ( s[ i / 8 ] & mask ) << ( i % 32 ); - } - - // append padding and length - blocks[ int(len >> 5) ] |= 0x80 << ( len % 32 ); - blocks[ int(( ( ( len + 64 ) >>> 9 ) << 4 ) + 14) ] = len; - return blocks; - } - - } -} +/* + 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.crypto { + + import com.adobe.utils.IntUtil; + import flash.utils.ByteArray; + /** + * The MD5 Message-Digest Algorithm + * + * Implementation based on algorithm description at + * http://www.faqs.org/rfcs/rfc1321.html + */ + public class MD5 { + + public static var digest:ByteArray; + /** + * Performs the MD5 hash algorithm on a string. + * + * @param s The string to hash + * @return A string containing the hash value of s + * @langversion ActionScript 3.0 + * @playerversion Flash 8.5 + * @tiptext + */ + + public static function hash(s:String) :String{ + //Convert to byteArray and send through hashBinary function + // so as to only have complex code in one location + var ba:ByteArray = new ByteArray(); + ba.writeUTFBytes(s); + return hashBinary(ba); + } + + public static function hashBytes(s:ByteArray) :String{ + return hashBinary(s); + } + + /** + * Performs the MD5 hash algorithm on a ByteArray. + * + * @param s The string to hash + * @return A string containing the hash value of s + * @langversion ActionScript 3.0 + * @playerversion Flash 8.5 + * @tiptext + */ + public static function hashBinary( s:ByteArray ):String { + // initialize the md buffers + var a:int = 1732584193; + var b:int = -271733879; + var c:int = -1732584194; + var d:int = 271733878; + + // variables to store previous values + var aa:int; + var bb:int; + var cc:int; + var dd:int; + + // create the blocks from the string and + // save the length as a local var to reduce + // lookup in the loop below + var x:Array = createBlocks( s ); + var len:int = x.length; + + // loop over all of the blocks + for ( var i:int = 0; i < len; i += 16) { + // save previous values + aa = a; + bb = b; + cc = c; + dd = d; + + // Round 1 + a = ff( a, b, c, d, x[int(i+ 0)], 7, -680876936 ); // 1 + d = ff( d, a, b, c, x[int(i+ 1)], 12, -389564586 ); // 2 + c = ff( c, d, a, b, x[int(i+ 2)], 17, 606105819 ); // 3 + b = ff( b, c, d, a, x[int(i+ 3)], 22, -1044525330 ); // 4 + a = ff( a, b, c, d, x[int(i+ 4)], 7, -176418897 ); // 5 + d = ff( d, a, b, c, x[int(i+ 5)], 12, 1200080426 ); // 6 + c = ff( c, d, a, b, x[int(i+ 6)], 17, -1473231341 ); // 7 + b = ff( b, c, d, a, x[int(i+ 7)], 22, -45705983 ); // 8 + a = ff( a, b, c, d, x[int(i+ 8)], 7, 1770035416 ); // 9 + d = ff( d, a, b, c, x[int(i+ 9)], 12, -1958414417 ); // 10 + c = ff( c, d, a, b, x[int(i+10)], 17, -42063 ); // 11 + b = ff( b, c, d, a, x[int(i+11)], 22, -1990404162 ); // 12 + a = ff( a, b, c, d, x[int(i+12)], 7, 1804603682 ); // 13 + d = ff( d, a, b, c, x[int(i+13)], 12, -40341101 ); // 14 + c = ff( c, d, a, b, x[int(i+14)], 17, -1502002290 ); // 15 + b = ff( b, c, d, a, x[int(i+15)], 22, 1236535329 ); // 16 + + // Round 2 + a = gg( a, b, c, d, x[int(i+ 1)], 5, -165796510 ); // 17 + d = gg( d, a, b, c, x[int(i+ 6)], 9, -1069501632 ); // 18 + c = gg( c, d, a, b, x[int(i+11)], 14, 643717713 ); // 19 + b = gg( b, c, d, a, x[int(i+ 0)], 20, -373897302 ); // 20 + a = gg( a, b, c, d, x[int(i+ 5)], 5, -701558691 ); // 21 + d = gg( d, a, b, c, x[int(i+10)], 9, 38016083 ); // 22 + c = gg( c, d, a, b, x[int(i+15)], 14, -660478335 ); // 23 + b = gg( b, c, d, a, x[int(i+ 4)], 20, -405537848 ); // 24 + a = gg( a, b, c, d, x[int(i+ 9)], 5, 568446438 ); // 25 + d = gg( d, a, b, c, x[int(i+14)], 9, -1019803690 ); // 26 + c = gg( c, d, a, b, x[int(i+ 3)], 14, -187363961 ); // 27 + b = gg( b, c, d, a, x[int(i+ 8)], 20, 1163531501 ); // 28 + a = gg( a, b, c, d, x[int(i+13)], 5, -1444681467 ); // 29 + d = gg( d, a, b, c, x[int(i+ 2)], 9, -51403784 ); // 30 + c = gg( c, d, a, b, x[int(i+ 7)], 14, 1735328473 ); // 31 + b = gg( b, c, d, a, x[int(i+12)], 20, -1926607734 ); // 32 + + // Round 3 + a = hh( a, b, c, d, x[int(i+ 5)], 4, -378558 ); // 33 + d = hh( d, a, b, c, x[int(i+ 8)], 11, -2022574463 ); // 34 + c = hh( c, d, a, b, x[int(i+11)], 16, 1839030562 ); // 35 + b = hh( b, c, d, a, x[int(i+14)], 23, -35309556 ); // 36 + a = hh( a, b, c, d, x[int(i+ 1)], 4, -1530992060 ); // 37 + d = hh( d, a, b, c, x[int(i+ 4)], 11, 1272893353 ); // 38 + c = hh( c, d, a, b, x[int(i+ 7)], 16, -155497632 ); // 39 + b = hh( b, c, d, a, x[int(i+10)], 23, -1094730640 ); // 40 + a = hh( a, b, c, d, x[int(i+13)], 4, 681279174 ); // 41 + d = hh( d, a, b, c, x[int(i+ 0)], 11, -358537222 ); // 42 + c = hh( c, d, a, b, x[int(i+ 3)], 16, -722521979 ); // 43 + b = hh( b, c, d, a, x[int(i+ 6)], 23, 76029189 ); // 44 + a = hh( a, b, c, d, x[int(i+ 9)], 4, -640364487 ); // 45 + d = hh( d, a, b, c, x[int(i+12)], 11, -421815835 ); // 46 + c = hh( c, d, a, b, x[int(i+15)], 16, 530742520 ); // 47 + b = hh( b, c, d, a, x[int(i+ 2)], 23, -995338651 ); // 48 + + // Round 4 + a = ii( a, b, c, d, x[int(i+ 0)], 6, -198630844 ); // 49 + d = ii( d, a, b, c, x[int(i+ 7)], 10, 1126891415 ); // 50 + c = ii( c, d, a, b, x[int(i+14)], 15, -1416354905 ); // 51 + b = ii( b, c, d, a, x[int(i+ 5)], 21, -57434055 ); // 52 + a = ii( a, b, c, d, x[int(i+12)], 6, 1700485571 ); // 53 + d = ii( d, a, b, c, x[int(i+ 3)], 10, -1894986606 ); // 54 + c = ii( c, d, a, b, x[int(i+10)], 15, -1051523 ); // 55 + b = ii( b, c, d, a, x[int(i+ 1)], 21, -2054922799 ); // 56 + a = ii( a, b, c, d, x[int(i+ 8)], 6, 1873313359 ); // 57 + d = ii( d, a, b, c, x[int(i+15)], 10, -30611744 ); // 58 + c = ii( c, d, a, b, x[int(i+ 6)], 15, -1560198380 ); // 59 + b = ii( b, c, d, a, x[int(i+13)], 21, 1309151649 ); // 60 + a = ii( a, b, c, d, x[int(i+ 4)], 6, -145523070 ); // 61 + d = ii( d, a, b, c, x[int(i+11)], 10, -1120210379 ); // 62 + c = ii( c, d, a, b, x[int(i+ 2)], 15, 718787259 ); // 63 + b = ii( b, c, d, a, x[int(i+ 9)], 21, -343485551 ); // 64 + + a += aa; + b += bb; + c += cc; + d += dd; + } + digest = new ByteArray() + digest.writeInt(a); + digest.writeInt(b); + digest.writeInt(c); + digest.writeInt(d); + digest.position = 0; + // Finish up by concatening the buffers with their hex output + return IntUtil.toHex( a ) + IntUtil.toHex( b ) + IntUtil.toHex( c ) + IntUtil.toHex( d ); + } + + /** + * Auxiliary function f as defined in RFC + */ + private static function f( x:int, y:int, z:int ):int { + return ( x & y ) | ( (~x) & z ); + } + + /** + * Auxiliary function g as defined in RFC + */ + private static function g( x:int, y:int, z:int ):int { + return ( x & z ) | ( y & (~z) ); + } + + /** + * Auxiliary function h as defined in RFC + */ + private static function h( x:int, y:int, z:int ):int { + return x ^ y ^ z; + } + + /** + * Auxiliary function i as defined in RFC + */ + private static function i( x:int, y:int, z:int ):int { + return y ^ ( x | (~z) ); + } + + /** + * A generic transformation function. The logic of ff, gg, hh, and + * ii are all the same, minus the function used, so pull that logic + * out and simplify the method bodies for the transoformation functions. + */ + private static function transform( func:Function, a:int, b:int, c:int, d:int, x:int, s:int, t:int):int { + var tmp:int = a + int( func( b, c, d ) ) + x + t; + return IntUtil.rol( tmp, s ) + b; + } + + /** + * ff transformation function + */ + private static function ff ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { + return transform( f, a, b, c, d, x, s, t ); + } + + /** + * gg transformation function + */ + private static function gg ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { + return transform( g, a, b, c, d, x, s, t ); + } + + /** + * hh transformation function + */ + private static function hh ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { + return transform( h, a, b, c, d, x, s, t ); + } + + /** + * ii transformation function + */ + private static function ii ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { + return transform( i, a, b, c, d, x, s, t ); + } + + /** + * Converts a string to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param s The string to split into blocks + * @return An array containing the blocks that s was + * split into. + */ + private static function createBlocks( s:ByteArray ):Array { + var blocks:Array = new Array(); + var len:int = s.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) { + blocks[ int(i >> 5) ] |= ( s[ i / 8 ] & mask ) << ( i % 32 ); + } + + // append padding and length + blocks[ int(len >> 5) ] |= 0x80 << ( len % 32 ); + blocks[ int(( ( ( len + 64 ) >>> 9 ) << 4 ) + 14) ] = len; + return blocks; + } + + } +} diff --git a/src/com/adobe/crypto/MD5Stream.as b/src/com/adobe/crypto/MD5Stream.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/crypto/SHA1.as b/src/com/adobe/crypto/SHA1.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/crypto/SHA224.as b/src/com/adobe/crypto/SHA224.as old mode 100644 new mode 100755 index ee15453..0a47b09 --- a/src/com/adobe/crypto/SHA224.as +++ b/src/com/adobe/crypto/SHA224.as @@ -1,257 +1,257 @@ -/* - 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.crypto -{ - import com.adobe.utils.IntUtil; - import flash.utils.ByteArray; - import mx.utils.Base64Encoder; - - /** - * The SHA-224 algorithm - * - * @see http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf - */ - public class SHA224 - { - public static var digest:ByteArray; - - /** - * Performs the SHA224 hash algorithm on a string. - * - * @param s The string to hash - * @return A string containing the hash value of s - * @langversion ActionScript 3.0 - * @playerversion 9.0 - * @tiptext - */ - public static function hash( s:String ):String { - var blocks:Array = createBlocksFromString( s ); - var byteArray:ByteArray = hashBlocks( blocks ); - return IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ); - } - - /** - * Performs the SHA224 hash algorithm on a ByteArray. - * - * @param data The ByteArray data to hash - * @return A string containing the hash value of data - * @langversion ActionScript 3.0 - * @playerversion 9.0 - */ - public static function hashBytes( data:ByteArray ):String - { - var blocks:Array = createBlocksFromByteArray( data ); - var byteArray:ByteArray = hashBlocks(blocks); - return IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ); - } - - /** - * Performs the SHA224 hash algorithm on a string, then does - * Base64 encoding on the result. - * - * @param s The string to hash - * @return The base64 encoded hash value of s - * @langversion ActionScript 3.0 - * @playerversion 9.0 - * @tiptext - */ - public static function hashToBase64( s:String ):String - { - var blocks:Array = createBlocksFromString( s ); - var byteArray:ByteArray = hashBlocks(blocks); - - // ByteArray.toString() returns the contents as a UTF-8 string, - // which we can't use because certain byte sequences might trigger - // a UTF-8 conversion. Instead, we convert the bytes to characters - // one by one. - var charsInByteArray:String = ""; - byteArray.position = 0; - for (var j:int = 0; j < byteArray.length; j++) - { - var byte:uint = byteArray.readUnsignedByte(); - charsInByteArray += String.fromCharCode(byte); - } - - var encoder:Base64Encoder = new Base64Encoder(); - encoder.encode(charsInByteArray); - return encoder.flush(); - } - - private static function hashBlocks( blocks:Array ):ByteArray { - var h0:int = 0xc1059ed8; - var h1:int = 0x367cd507; - var h2:int = 0x3070dd17; - var h3:int = 0xf70e5939; - var h4:int = 0xffc00b31; - var h5:int = 0x68581511; - var h6:int = 0x64f98fa7; - var h7:int = 0xbefa4fa4; - - var k:Array = new Array(0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2); - - var len:int = blocks.length; - var w:Array = new Array(); - - // loop over all of the blocks - for ( var i:int = 0; i < len; i += 16 ) { - - var a:int = h0; - var b:int = h1; - var c:int = h2; - var d:int = h3; - var e:int = h4; - var f:int = h5; - var g:int = h6; - var h:int = h7; - - for(var t:int = 0; t < 64; t++) { - - if ( t < 16 ) { - w[t] = blocks[ i + t ]; - if(isNaN(w[t])) { w[t] = 0; } - } else { - var ws0:int = IntUtil.ror(w[t-15], 7) ^ IntUtil.ror(w[t-15], 18) ^ (w[t-15] >>> 3); - var ws1:int = IntUtil.ror(w[t-2], 17) ^ IntUtil.ror(w[t-2], 19) ^ (w[t-2] >>> 10); - w[t] = w[t-16] + ws0 + w[t-7] + ws1; - } - - var s0:int = IntUtil.ror(a, 2) ^ IntUtil.ror(a, 13) ^ IntUtil.ror(a, 22); - var maj:int = (a & b) ^ (a & c) ^ (b & c); - var t2:int = s0 + maj; - var s1:int = IntUtil.ror(e, 6) ^ IntUtil.ror(e, 11) ^ IntUtil.ror(e, 25); - var ch:int = (e & f) ^ ((~e) & g); - var t1:int = h + s1 + ch + k[t] + w[t]; - - h = g; - g = f; - f = e; - e = d + t1; - d = c; - c = b; - b = a; - a = t1 + t2; - } - - //Add this chunk's hash to result so far: - h0 += a; - h1 += b; - h2 += c; - h3 += d; - h4 += e; - h5 += f; - h6 += g; - h7 += h; - } - - var byteArray:ByteArray = new ByteArray(); - byteArray.writeInt(h0); - byteArray.writeInt(h1); - byteArray.writeInt(h2); - byteArray.writeInt(h3); - byteArray.writeInt(h4); - byteArray.writeInt(h5); - byteArray.writeInt(h6); - byteArray.position = 0; - - digest = new ByteArray(); - digest.writeBytes(byteArray); - digest.position = 0; - return byteArray; - } - - /** - * Converts a ByteArray to a sequence of 16-word blocks - * that we'll do the processing on. Appends padding - * and length in the process. - * - * @param data The data to split into blocks - * @return An array containing the blocks into which data was split - */ - private static function createBlocksFromByteArray( data:ByteArray ):Array - { - var oldPosition:int = data.position; - data.position = 0; - - var blocks:Array = new Array(); - var len:int = data.length * 8; - var mask:int = 0xFF; // ignore hi byte of characters > 0xFF - for( var i:int = 0; i < len; i += 8 ) - { - blocks[ i >> 5 ] |= ( data.readByte() & mask ) << ( 24 - i % 32 ); - } - - // append padding and length - blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); - blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; - - data.position = oldPosition; - - return blocks; - } - - /** - * Converts a string to a sequence of 16-word blocks - * that we'll do the processing on. Appends padding - * and length in the process. - * - * @param s The string to split into blocks - * @return An array containing the blocks that s was split into. - */ - private static function createBlocksFromString( s:String ):Array - { - var blocks:Array = new Array(); - var len:int = s.length * 8; - var mask:int = 0xFF; // ignore hi byte of characters > 0xFF - for( var i:int = 0; i < len; i += 8 ) { - blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( 24 - i % 32 ); - } - - // append padding and length - blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); - blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; - return blocks; - } - } -} +/* + 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.crypto +{ + import com.adobe.utils.IntUtil; + import flash.utils.ByteArray; + import mx.utils.Base64Encoder; + + /** + * The SHA-224 algorithm + * + * @see http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf + */ + public class SHA224 + { + public static var digest:ByteArray; + + /** + * Performs the SHA224 hash algorithm on a string. + * + * @param s The string to hash + * @return A string containing the hash value of s + * @langversion ActionScript 3.0 + * @playerversion 9.0 + * @tiptext + */ + public static function hash( s:String ):String { + var blocks:Array = createBlocksFromString( s ); + var byteArray:ByteArray = hashBlocks( blocks ); + return IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ); + } + + /** + * Performs the SHA224 hash algorithm on a ByteArray. + * + * @param data The ByteArray data to hash + * @return A string containing the hash value of data + * @langversion ActionScript 3.0 + * @playerversion 9.0 + */ + public static function hashBytes( data:ByteArray ):String + { + var blocks:Array = createBlocksFromByteArray( data ); + var byteArray:ByteArray = hashBlocks(blocks); + return IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ); + } + + /** + * Performs the SHA224 hash algorithm on a string, then does + * Base64 encoding on the result. + * + * @param s The string to hash + * @return The base64 encoded hash value of s + * @langversion ActionScript 3.0 + * @playerversion 9.0 + * @tiptext + */ + public static function hashToBase64( s:String ):String + { + var blocks:Array = createBlocksFromString( s ); + var byteArray:ByteArray = hashBlocks(blocks); + + // ByteArray.toString() returns the contents as a UTF-8 string, + // which we can't use because certain byte sequences might trigger + // a UTF-8 conversion. Instead, we convert the bytes to characters + // one by one. + var charsInByteArray:String = ""; + byteArray.position = 0; + for (var j:int = 0; j < byteArray.length; j++) + { + var byte:uint = byteArray.readUnsignedByte(); + charsInByteArray += String.fromCharCode(byte); + } + + var encoder:Base64Encoder = new Base64Encoder(); + encoder.encode(charsInByteArray); + return encoder.flush(); + } + + private static function hashBlocks( blocks:Array ):ByteArray { + var h0:int = 0xc1059ed8; + var h1:int = 0x367cd507; + var h2:int = 0x3070dd17; + var h3:int = 0xf70e5939; + var h4:int = 0xffc00b31; + var h5:int = 0x68581511; + var h6:int = 0x64f98fa7; + var h7:int = 0xbefa4fa4; + + var k:Array = new Array(0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2); + + var len:int = blocks.length; + var w:Array = new Array(); + + // loop over all of the blocks + for ( var i:int = 0; i < len; i += 16 ) { + + var a:int = h0; + var b:int = h1; + var c:int = h2; + var d:int = h3; + var e:int = h4; + var f:int = h5; + var g:int = h6; + var h:int = h7; + + for(var t:int = 0; t < 64; t++) { + + if ( t < 16 ) { + w[t] = blocks[ i + t ]; + if(isNaN(w[t])) { w[t] = 0; } + } else { + var ws0:int = IntUtil.ror(w[t-15], 7) ^ IntUtil.ror(w[t-15], 18) ^ (w[t-15] >>> 3); + var ws1:int = IntUtil.ror(w[t-2], 17) ^ IntUtil.ror(w[t-2], 19) ^ (w[t-2] >>> 10); + w[t] = w[t-16] + ws0 + w[t-7] + ws1; + } + + var s0:int = IntUtil.ror(a, 2) ^ IntUtil.ror(a, 13) ^ IntUtil.ror(a, 22); + var maj:int = (a & b) ^ (a & c) ^ (b & c); + var t2:int = s0 + maj; + var s1:int = IntUtil.ror(e, 6) ^ IntUtil.ror(e, 11) ^ IntUtil.ror(e, 25); + var ch:int = (e & f) ^ ((~e) & g); + var t1:int = h + s1 + ch + k[t] + w[t]; + + h = g; + g = f; + f = e; + e = d + t1; + d = c; + c = b; + b = a; + a = t1 + t2; + } + + //Add this chunk's hash to result so far: + h0 += a; + h1 += b; + h2 += c; + h3 += d; + h4 += e; + h5 += f; + h6 += g; + h7 += h; + } + + var byteArray:ByteArray = new ByteArray(); + byteArray.writeInt(h0); + byteArray.writeInt(h1); + byteArray.writeInt(h2); + byteArray.writeInt(h3); + byteArray.writeInt(h4); + byteArray.writeInt(h5); + byteArray.writeInt(h6); + byteArray.position = 0; + + digest = new ByteArray(); + digest.writeBytes(byteArray); + digest.position = 0; + return byteArray; + } + + /** + * Converts a ByteArray to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param data The data to split into blocks + * @return An array containing the blocks into which data was split + */ + private static function createBlocksFromByteArray( data:ByteArray ):Array + { + var oldPosition:int = data.position; + data.position = 0; + + var blocks:Array = new Array(); + var len:int = data.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) + { + blocks[ i >> 5 ] |= ( data.readByte() & mask ) << ( 24 - i % 32 ); + } + + // append padding and length + blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); + blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; + + data.position = oldPosition; + + return blocks; + } + + /** + * Converts a string to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param s The string to split into blocks + * @return An array containing the blocks that s was split into. + */ + private static function createBlocksFromString( s:String ):Array + { + var blocks:Array = new Array(); + var len:int = s.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) { + blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( 24 - i % 32 ); + } + + // append padding and length + blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); + blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; + return blocks; + } + } +} diff --git a/src/com/adobe/crypto/SHA256.as b/src/com/adobe/crypto/SHA256.as old mode 100644 new mode 100755 index 09a2ba2..2990b14 --- a/src/com/adobe/crypto/SHA256.as +++ b/src/com/adobe/crypto/SHA256.as @@ -1,261 +1,261 @@ -/* - 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.crypto -{ - import com.adobe.utils.IntUtil; - import flash.utils.ByteArray; - import mx.utils.Base64Encoder; - - /** - * The SHA-256 algorithm - * - * @see http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf - */ - public class SHA256 - { - public static var digest:ByteArray; - /** - * Performs the SHA256 hash algorithm on a string. - * - * @param s The string to hash - * @return A string containing the hash value of s - * @langversion ActionScript 3.0 - * @playerversion 9.0 - * @tiptext - */ - public static function hash( s:String ):String { - var blocks:Array = createBlocksFromString( s ); - var byteArray:ByteArray = hashBlocks( blocks ); - - return IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ); - } - - /** - * Performs the SHA256 hash algorithm on a ByteArray. - * - * @param data The ByteArray data to hash - * @return A string containing the hash value of data - * @langversion ActionScript 3.0 - * @playerversion 9.0 - */ - public static function hashBytes( data:ByteArray ):String - { - var blocks:Array = createBlocksFromByteArray( data ); - var byteArray:ByteArray = hashBlocks(blocks); - - return IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ) - + IntUtil.toHex( byteArray.readInt(), true ); - } - - /** - * Performs the SHA256 hash algorithm on a string, then does - * Base64 encoding on the result. - * - * @param s The string to hash - * @return The base64 encoded hash value of s - * @langversion ActionScript 3.0 - * @playerversion 9.0 - * @tiptext - */ - public static function hashToBase64( s:String ):String - { - var blocks:Array = createBlocksFromString( s ); - var byteArray:ByteArray = hashBlocks(blocks); - - // ByteArray.toString() returns the contents as a UTF-8 string, - // which we can't use because certain byte sequences might trigger - // a UTF-8 conversion. Instead, we convert the bytes to characters - // one by one. - var charsInByteArray:String = ""; - byteArray.position = 0; - for (var j:int = 0; j < byteArray.length; j++) - { - var byte:uint = byteArray.readUnsignedByte(); - charsInByteArray += String.fromCharCode(byte); - } - - var encoder:Base64Encoder = new Base64Encoder(); - encoder.encode(charsInByteArray); - return encoder.flush(); - } - - private static function hashBlocks( blocks:Array ):ByteArray { - var h0:int = 0x6a09e667; - var h1:int = 0xbb67ae85; - var h2:int = 0x3c6ef372; - var h3:int = 0xa54ff53a; - var h4:int = 0x510e527f; - var h5:int = 0x9b05688c; - var h6:int = 0x1f83d9ab; - var h7:int = 0x5be0cd19; - - var k:Array = new Array(0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2); - - var len:int = blocks.length; - var w:Array = new Array( 64 ); - - // loop over all of the blocks - for ( var i:int = 0; i < len; i += 16 ) { - - var a:int = h0; - var b:int = h1; - var c:int = h2; - var d:int = h3; - var e:int = h4; - var f:int = h5; - var g:int = h6; - var h:int = h7; - - for(var t:int = 0; t < 64; t++) { - - if ( t < 16 ) { - w[t] = blocks[ i + t ]; - if(isNaN(w[t])) { w[t] = 0; } - } else { - var ws0:int = IntUtil.ror(w[t-15], 7) ^ IntUtil.ror(w[t-15], 18) ^ (w[t-15] >>> 3); - var ws1:int = IntUtil.ror(w[t-2], 17) ^ IntUtil.ror(w[t-2], 19) ^ (w[t-2] >>> 10); - w[t] = w[t-16] + ws0 + w[t-7] + ws1; - } - - var s0:int = IntUtil.ror(a, 2) ^ IntUtil.ror(a, 13) ^ IntUtil.ror(a, 22); - var maj:int = (a & b) ^ (a & c) ^ (b & c); - var t2:int = s0 + maj; - var s1:int = IntUtil.ror(e, 6) ^ IntUtil.ror(e, 11) ^ IntUtil.ror(e, 25); - var ch:int = (e & f) ^ ((~e) & g); - var t1:int = h + s1 + ch + k[t] + w[t]; - - h = g; - g = f; - f = e; - e = d + t1; - d = c; - c = b; - b = a; - a = t1 + t2; - } - - //Add this chunk's hash to result so far: - h0 += a; - h1 += b; - h2 += c; - h3 += d; - h4 += e; - h5 += f; - h6 += g; - h7 += h; - } - - var byteArray:ByteArray = new ByteArray(); - byteArray.writeInt(h0); - byteArray.writeInt(h1); - byteArray.writeInt(h2); - byteArray.writeInt(h3); - byteArray.writeInt(h4); - byteArray.writeInt(h5); - byteArray.writeInt(h6); - byteArray.writeInt(h7); - byteArray.position = 0; - - digest = new ByteArray(); - digest.writeBytes(byteArray); - digest.position = 0; - return byteArray; - } - - /** - * Converts a ByteArray to a sequence of 16-word blocks - * that we'll do the processing on. Appends padding - * and length in the process. - * - * @param data The data to split into blocks - * @return An array containing the blocks into which data was split - */ - private static function createBlocksFromByteArray( data:ByteArray ):Array - { - var oldPosition:int = data.position; - data.position = 0; - - var blocks:Array = new Array(); - var len:int = data.length * 8; - var mask:int = 0xFF; // ignore hi byte of characters > 0xFF - for( var i:int = 0; i < len; i += 8 ) - { - blocks[ i >> 5 ] |= ( data.readByte() & mask ) << ( 24 - i % 32 ); - } - - // append padding and length - blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); - blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; - - data.position = oldPosition; - - return blocks; - } - - /** - * Converts a string to a sequence of 16-word blocks - * that we'll do the processing on. Appends padding - * and length in the process. - * - * @param s The string to split into blocks - * @return An array containing the blocks that s was split into. - */ - private static function createBlocksFromString( s:String ):Array - { - var blocks:Array = new Array(); - var len:int = s.length * 8; - var mask:int = 0xFF; // ignore hi byte of characters > 0xFF - for( var i:int = 0; i < len; i += 8 ) { - blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( 24 - i % 32 ); - } - - // append padding and length - blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); - blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; - return blocks; - } - } -} +/* + 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.crypto +{ + import com.adobe.utils.IntUtil; + import flash.utils.ByteArray; + import mx.utils.Base64Encoder; + + /** + * The SHA-256 algorithm + * + * @see http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf + */ + public class SHA256 + { + public static var digest:ByteArray; + /** + * Performs the SHA256 hash algorithm on a string. + * + * @param s The string to hash + * @return A string containing the hash value of s + * @langversion ActionScript 3.0 + * @playerversion 9.0 + * @tiptext + */ + public static function hash( s:String ):String { + var blocks:Array = createBlocksFromString( s ); + var byteArray:ByteArray = hashBlocks( blocks ); + + return IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ); + } + + /** + * Performs the SHA256 hash algorithm on a ByteArray. + * + * @param data The ByteArray data to hash + * @return A string containing the hash value of data + * @langversion ActionScript 3.0 + * @playerversion 9.0 + */ + public static function hashBytes( data:ByteArray ):String + { + var blocks:Array = createBlocksFromByteArray( data ); + var byteArray:ByteArray = hashBlocks(blocks); + + return IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ); + } + + /** + * Performs the SHA256 hash algorithm on a string, then does + * Base64 encoding on the result. + * + * @param s The string to hash + * @return The base64 encoded hash value of s + * @langversion ActionScript 3.0 + * @playerversion 9.0 + * @tiptext + */ + public static function hashToBase64( s:String ):String + { + var blocks:Array = createBlocksFromString( s ); + var byteArray:ByteArray = hashBlocks(blocks); + + // ByteArray.toString() returns the contents as a UTF-8 string, + // which we can't use because certain byte sequences might trigger + // a UTF-8 conversion. Instead, we convert the bytes to characters + // one by one. + var charsInByteArray:String = ""; + byteArray.position = 0; + for (var j:int = 0; j < byteArray.length; j++) + { + var byte:uint = byteArray.readUnsignedByte(); + charsInByteArray += String.fromCharCode(byte); + } + + var encoder:Base64Encoder = new Base64Encoder(); + encoder.encode(charsInByteArray); + return encoder.flush(); + } + + private static function hashBlocks( blocks:Array ):ByteArray { + var h0:int = 0x6a09e667; + var h1:int = 0xbb67ae85; + var h2:int = 0x3c6ef372; + var h3:int = 0xa54ff53a; + var h4:int = 0x510e527f; + var h5:int = 0x9b05688c; + var h6:int = 0x1f83d9ab; + var h7:int = 0x5be0cd19; + + var k:Array = new Array(0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2); + + var len:int = blocks.length; + var w:Array = new Array( 64 ); + + // loop over all of the blocks + for ( var i:int = 0; i < len; i += 16 ) { + + var a:int = h0; + var b:int = h1; + var c:int = h2; + var d:int = h3; + var e:int = h4; + var f:int = h5; + var g:int = h6; + var h:int = h7; + + for(var t:int = 0; t < 64; t++) { + + if ( t < 16 ) { + w[t] = blocks[ i + t ]; + if(isNaN(w[t])) { w[t] = 0; } + } else { + var ws0:int = IntUtil.ror(w[t-15], 7) ^ IntUtil.ror(w[t-15], 18) ^ (w[t-15] >>> 3); + var ws1:int = IntUtil.ror(w[t-2], 17) ^ IntUtil.ror(w[t-2], 19) ^ (w[t-2] >>> 10); + w[t] = w[t-16] + ws0 + w[t-7] + ws1; + } + + var s0:int = IntUtil.ror(a, 2) ^ IntUtil.ror(a, 13) ^ IntUtil.ror(a, 22); + var maj:int = (a & b) ^ (a & c) ^ (b & c); + var t2:int = s0 + maj; + var s1:int = IntUtil.ror(e, 6) ^ IntUtil.ror(e, 11) ^ IntUtil.ror(e, 25); + var ch:int = (e & f) ^ ((~e) & g); + var t1:int = h + s1 + ch + k[t] + w[t]; + + h = g; + g = f; + f = e; + e = d + t1; + d = c; + c = b; + b = a; + a = t1 + t2; + } + + //Add this chunk's hash to result so far: + h0 += a; + h1 += b; + h2 += c; + h3 += d; + h4 += e; + h5 += f; + h6 += g; + h7 += h; + } + + var byteArray:ByteArray = new ByteArray(); + byteArray.writeInt(h0); + byteArray.writeInt(h1); + byteArray.writeInt(h2); + byteArray.writeInt(h3); + byteArray.writeInt(h4); + byteArray.writeInt(h5); + byteArray.writeInt(h6); + byteArray.writeInt(h7); + byteArray.position = 0; + + digest = new ByteArray(); + digest.writeBytes(byteArray); + digest.position = 0; + return byteArray; + } + + /** + * Converts a ByteArray to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param data The data to split into blocks + * @return An array containing the blocks into which data was split + */ + private static function createBlocksFromByteArray( data:ByteArray ):Array + { + var oldPosition:int = data.position; + data.position = 0; + + var blocks:Array = new Array(); + var len:int = data.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) + { + blocks[ i >> 5 ] |= ( data.readByte() & mask ) << ( 24 - i % 32 ); + } + + // append padding and length + blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); + blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; + + data.position = oldPosition; + + return blocks; + } + + /** + * Converts a string to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param s The string to split into blocks + * @return An array containing the blocks that s was split into. + */ + private static function createBlocksFromString( s:String ):Array + { + var blocks:Array = new Array(); + var len:int = s.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) { + blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( 24 - i % 32 ); + } + + // append padding and length + blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); + blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; + return blocks; + } + } +} diff --git a/src/com/adobe/crypto/WSSEUsernameToken.as b/src/com/adobe/crypto/WSSEUsernameToken.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/errors/IllegalStateError.as b/src/com/adobe/errors/IllegalStateError.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/fileformats/vcard/Address.as b/src/com/adobe/fileformats/vcard/Address.as old mode 100644 new mode 100755 index a368ffb..465faa5 --- a/src/com/adobe/fileformats/vcard/Address.as +++ b/src/com/adobe/fileformats/vcard/Address.as @@ -1,47 +1,47 @@ -/* - 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.fileformats.vcard -{ - public class Address - { - public var type:String; - public var street:String; - public var city:String; - public var state:String; - public var postalCode:String; - - public function toString():String - { - return (street + " " + city + ", " + state + " " + postalCode); - } - } +/* + 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.fileformats.vcard +{ + public class Address + { + public var type:String; + public var street:String; + public var city:String; + public var state:String; + public var postalCode:String; + + public function toString():String + { + return (street + " " + city + ", " + state + " " + postalCode); + } + } } \ No newline at end of file diff --git a/src/com/adobe/fileformats/vcard/Email.as b/src/com/adobe/fileformats/vcard/Email.as old mode 100644 new mode 100755 index 071c39e..67ff3cc --- a/src/com/adobe/fileformats/vcard/Email.as +++ b/src/com/adobe/fileformats/vcard/Email.as @@ -1,39 +1,39 @@ -/* - 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.fileformats.vcard -{ - public class Email - { - public var type:String; - public var address:String; - } +/* + 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.fileformats.vcard +{ + public class Email + { + public var type:String; + public var address:String; + } } \ No newline at end of file diff --git a/src/com/adobe/fileformats/vcard/Phone.as b/src/com/adobe/fileformats/vcard/Phone.as old mode 100644 new mode 100755 index 27f98e4..9dfc671 --- a/src/com/adobe/fileformats/vcard/Phone.as +++ b/src/com/adobe/fileformats/vcard/Phone.as @@ -1,39 +1,39 @@ -/* - 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.fileformats.vcard -{ - public class Phone - { - public var type:String; - public var number:String; - } +/* + 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.fileformats.vcard +{ + public class Phone + { + public var type:String; + public var number:String; + } } \ No newline at end of file diff --git a/src/com/adobe/fileformats/vcard/VCard.as b/src/com/adobe/fileformats/vcard/VCard.as old mode 100644 new mode 100755 index d6bc283..8a28089 --- a/src/com/adobe/fileformats/vcard/VCard.as +++ b/src/com/adobe/fileformats/vcard/VCard.as @@ -1,54 +1,54 @@ -/* - 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.fileformats.vcard -{ - import flash.utils.ByteArray; - - public class VCard - { - public var fullName:String; - public var orgs:Array; - public var title:String; - public var image:ByteArray; - public var phones:Array; - public var emails:Array; - public var addresses:Array; - - public function VCard() - { - orgs = new Array(); - phones = new Array(); - emails = new Array(); - addresses = new Array(); - } - } +/* + 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.fileformats.vcard +{ + import flash.utils.ByteArray; + + public class VCard + { + public var fullName:String; + public var orgs:Array; + public var title:String; + public var image:ByteArray; + public var phones:Array; + public var emails:Array; + public var addresses:Array; + + public function VCard() + { + orgs = new Array(); + phones = new Array(); + emails = new Array(); + addresses = new Array(); + } + } } \ No newline at end of file diff --git a/src/com/adobe/fileformats/vcard/VCardParser.as b/src/com/adobe/fileformats/vcard/VCardParser.as old mode 100644 new mode 100755 index 45c954a..c15e34d --- a/src/com/adobe/fileformats/vcard/VCardParser.as +++ b/src/com/adobe/fileformats/vcard/VCardParser.as @@ -1,246 +1,246 @@ -/* - 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.fileformats.vcard -{ - import mx.utils.Base64Decoder; - import mx.utils.StringUtil; - - public class VCardParser - { - public static function parse(vcardStr:String):Array - { - var vcards:Array = new Array(); - var lines:Array = vcardStr.split(/\r\n/); - var vcard:VCard; - var type:String; - var typeTmp:String; - var line:String; - - for (var i:uint = 0; i < lines.length; ++i) - { - line = lines[i]; - if (line == "BEGIN:VCARD") - { - vcard = new VCard(); - } - else if (line == "END:VCARD") - { - if (vcard != null) - { - vcards.push(vcard); - } - } - else if(line.search(/^ORG/i) != -1) - { - var org:String = line.substring(4, line.length); - var orgArray:Array = org.split(";"); - for each (var orgToken:String in orgArray) - { - if (StringUtil.trim(orgToken).length > 0) - { - vcard.orgs.push(orgToken); - } - } - } - else if(line.search(/^TITLE/i) != -1) - { - var title:String = line.substring(6, line.length); - vcard.title = title; - } - else if (line.search(/^FN:/i) != -1) - { - var fullName:String = line.substring(3, line.length); - vcard.fullName = fullName; - } - else if (line.search(/^TEL/i) != -1) - { - type = new String(); - typeTmp = new String(); - var phone:Phone = new Phone(); - var number:String; - var phoneTokens:Array = line.split(";"); - for each (var phoneToken:String in phoneTokens) - { - if (phoneToken.search(/^TYPE=/i) != -1) - { - if (phoneToken.indexOf(":") != -1) - { - typeTmp = phoneToken.substring(5, phoneToken.indexOf(":")); - number = phoneToken.substring(phoneToken.indexOf(":")+1, phoneToken.length); - } - else - { - typeTmp = phoneToken.substring(5, phoneToken.length); - } - - typeTmp = typeTmp.toLocaleLowerCase(); - - if (typeTmp == "pref") - { - continue; - } - if (type.length != 0) - { - type += (" "); - } - type += typeTmp; - } - } - if (type.length > 0 && number != null) - { - phone.type = type; - phone.number = number; - } - vcard.phones.push(phone); - } - else if (line.search(/^EMAIL/i) != -1) - { - type = new String(); - typeTmp = new String(); - var email:Email = new Email(); - var emailAddress:String; - var emailTokens:Array = line.split(";"); - for each (var emailToken:String in emailTokens) - { - if (emailToken.search(/^TYPE=/i) != -1) - { - if (emailToken.indexOf(":") != -1) - { - typeTmp = emailToken.substring(5, emailToken.indexOf(":")); - emailAddress = emailToken.substring(emailToken.indexOf(":")+1, emailToken.length); - } - else - { - typeTmp = emailToken.substring(5, emailToken.length); - } - - typeTmp = typeTmp.toLocaleLowerCase(); - - if (typeTmp == "pref" || typeTmp == "internet") - { - continue; - } - if (type.length != 0) - { - type += (" "); - } - type += typeTmp; - } - } - if (type.length > 0 && emailAddress != null) - { - email.type = type; - email.address = emailAddress; - } - vcard.emails.push(email); - } - else if (line.indexOf("ADR;") != -1) - { - var addressTokens:Array = line.split(";"); - var address:Address = new Address(); - for (var j:uint = 0; j < addressTokens.length; ++j) - { - var addressToken:String = addressTokens[j]; - if (addressToken.search(/^home:+$/i) != -1) // For Outlook, which uses non-standard vCards. - { - address.type = "home"; - } - else if (addressToken.search(/^work:+$/i) != -1) // For Outlook, which uses non-standard vCards. - { - address.type = "work"; - } - if (addressToken.search(/^type=/i) != -1) // The "type" parameter is the standard way (which Address Book uses) - { - // First, remove the optional ":" character. - addressToken = addressToken.replace(/:/,""); - var addressType:String = addressToken.substring(5, addressToken.length).toLowerCase(); - if (addressType == "pref") // Not interested in which one is preferred. - { - continue; - } - else if (addressType.indexOf("home") != -1) // home - { - addressType = "home"; - } - else if (addressType.indexOf("work") != -1) // work - { - addressType = "work"; - } - else if (addressType.indexOf(",") != -1) // if the comma technique is used, just use the first one - { - var typeTokens:Array = addressType.split(","); - for each (var typeToken:String in typeTokens) - { - if (typeToken != "pref") - { - addressType = typeToken; - break; - } - } - } - address.type = addressType; - } - else if (addressToken.search(/^\d/) != -1 && address.street == null) - { - address.street = addressToken.replace(/\\n/, ""); - address.city = addressTokens[j+1]; - address.state = addressTokens[j+2]; - address.postalCode = addressTokens[j+3]; - } - } - if (address.type != null && address.street != null) - { - vcard.addresses.push(address); - } - - } - else if (line.search(/^PHOTO;BASE64/i) != -1) - { - var imageStr:String = new String(); - for (var k:uint = i+1; k < lines.length; ++k) - { - imageStr += lines[k]; - //if (lines[k].search(/.+\=$/) != -1) // Very slow in Mac due to RegEx bug - if (lines[k].indexOf('=') != -1) - { - var decoder:Base64Decoder = new Base64Decoder(); - decoder.decode(imageStr); - vcard.image = decoder.flush(); - break; - } - } - } - } - return vcards; - } - } +/* + 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.fileformats.vcard +{ + import mx.utils.Base64Decoder; + import mx.utils.StringUtil; + + public class VCardParser + { + public static function parse(vcardStr:String):Array + { + var vcards:Array = new Array(); + var lines:Array = vcardStr.split(/\r\n/); + var vcard:VCard; + var type:String; + var typeTmp:String; + var line:String; + + for (var i:uint = 0; i < lines.length; ++i) + { + line = lines[i]; + if (line == "BEGIN:VCARD") + { + vcard = new VCard(); + } + else if (line == "END:VCARD") + { + if (vcard != null) + { + vcards.push(vcard); + } + } + else if(line.search(/^ORG/i) != -1) + { + var org:String = line.substring(4, line.length); + var orgArray:Array = org.split(";"); + for each (var orgToken:String in orgArray) + { + if (StringUtil.trim(orgToken).length > 0) + { + vcard.orgs.push(orgToken); + } + } + } + else if(line.search(/^TITLE/i) != -1) + { + var title:String = line.substring(6, line.length); + vcard.title = title; + } + else if (line.search(/^FN:/i) != -1) + { + var fullName:String = line.substring(3, line.length); + vcard.fullName = fullName; + } + else if (line.search(/^TEL/i) != -1) + { + type = new String(); + typeTmp = new String(); + var phone:Phone = new Phone(); + var number:String; + var phoneTokens:Array = line.split(";"); + for each (var phoneToken:String in phoneTokens) + { + if (phoneToken.search(/^TYPE=/i) != -1) + { + if (phoneToken.indexOf(":") != -1) + { + typeTmp = phoneToken.substring(5, phoneToken.indexOf(":")); + number = phoneToken.substring(phoneToken.indexOf(":")+1, phoneToken.length); + } + else + { + typeTmp = phoneToken.substring(5, phoneToken.length); + } + + typeTmp = typeTmp.toLocaleLowerCase(); + + if (typeTmp == "pref") + { + continue; + } + if (type.length != 0) + { + type += (" "); + } + type += typeTmp; + } + } + if (type.length > 0 && number != null) + { + phone.type = type; + phone.number = number; + } + vcard.phones.push(phone); + } + else if (line.search(/^EMAIL/i) != -1) + { + type = new String(); + typeTmp = new String(); + var email:Email = new Email(); + var emailAddress:String; + var emailTokens:Array = line.split(";"); + for each (var emailToken:String in emailTokens) + { + if (emailToken.search(/^TYPE=/i) != -1) + { + if (emailToken.indexOf(":") != -1) + { + typeTmp = emailToken.substring(5, emailToken.indexOf(":")); + emailAddress = emailToken.substring(emailToken.indexOf(":")+1, emailToken.length); + } + else + { + typeTmp = emailToken.substring(5, emailToken.length); + } + + typeTmp = typeTmp.toLocaleLowerCase(); + + if (typeTmp == "pref" || typeTmp == "internet") + { + continue; + } + if (type.length != 0) + { + type += (" "); + } + type += typeTmp; + } + } + if (type.length > 0 && emailAddress != null) + { + email.type = type; + email.address = emailAddress; + } + vcard.emails.push(email); + } + else if (line.indexOf("ADR;") != -1) + { + var addressTokens:Array = line.split(";"); + var address:Address = new Address(); + for (var j:uint = 0; j < addressTokens.length; ++j) + { + var addressToken:String = addressTokens[j]; + if (addressToken.search(/^home:+$/i) != -1) // For Outlook, which uses non-standard vCards. + { + address.type = "home"; + } + else if (addressToken.search(/^work:+$/i) != -1) // For Outlook, which uses non-standard vCards. + { + address.type = "work"; + } + if (addressToken.search(/^type=/i) != -1) // The "type" parameter is the standard way (which Address Book uses) + { + // First, remove the optional ":" character. + addressToken = addressToken.replace(/:/,""); + var addressType:String = addressToken.substring(5, addressToken.length).toLowerCase(); + if (addressType == "pref") // Not interested in which one is preferred. + { + continue; + } + else if (addressType.indexOf("home") != -1) // home + { + addressType = "home"; + } + else if (addressType.indexOf("work") != -1) // work + { + addressType = "work"; + } + else if (addressType.indexOf(",") != -1) // if the comma technique is used, just use the first one + { + var typeTokens:Array = addressType.split(","); + for each (var typeToken:String in typeTokens) + { + if (typeToken != "pref") + { + addressType = typeToken; + break; + } + } + } + address.type = addressType; + } + else if (addressToken.search(/^\d/) != -1 && address.street == null) + { + address.street = addressToken.replace(/\\n/, ""); + address.city = addressTokens[j+1]; + address.state = addressTokens[j+2]; + address.postalCode = addressTokens[j+3]; + } + } + if (address.type != null && address.street != null) + { + vcard.addresses.push(address); + } + + } + else if (line.search(/^PHOTO;BASE64/i) != -1) + { + var imageStr:String = new String(); + for (var k:uint = i+1; k < lines.length; ++k) + { + imageStr += lines[k]; + //if (lines[k].search(/.+\=$/) != -1) // Very slow in Mac due to RegEx bug + if (lines[k].indexOf('=') != -1) + { + var decoder:Base64Decoder = new Base64Decoder(); + decoder.decode(imageStr); + vcard.image = decoder.flush(); + break; + } + } + } + } + return vcards; + } + } } \ No newline at end of file diff --git a/src/com/adobe/images/BitString.as b/src/com/adobe/images/BitString.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/images/JPGEncoder.as b/src/com/adobe/images/JPGEncoder.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/images/PNGEncoder.as b/src/com/adobe/images/PNGEncoder.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/net/DynamicURLLoader.as b/src/com/adobe/net/DynamicURLLoader.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/net/IURIResolver.as b/src/com/adobe/net/IURIResolver.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/net/MimeTypeMap.as b/src/com/adobe/net/MimeTypeMap.as old mode 100644 new mode 100755 index 32e40a4..edefd81 --- a/src/com/adobe/net/MimeTypeMap.as +++ b/src/com/adobe/net/MimeTypeMap.as @@ -1,196 +1,196 @@ -/* - 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.net -{ - public class MimeTypeMap - { - private var types:Array = - [["application/andrew-inset","ez"], - ["application/atom+xml","atom"], - ["application/mac-binhex40","hqx"], - ["application/mac-compactpro","cpt"], - ["application/mathml+xml","mathml"], - ["application/msword","doc"], - ["application/octet-stream","bin","dms","lha","lzh","exe","class","so","dll","dmg"], - ["application/oda","oda"], - ["application/ogg","ogg"], - ["application/pdf","pdf"], - ["application/postscript","ai","eps","ps"], - ["application/rdf+xml","rdf"], - ["application/smil","smi","smil"], - ["application/srgs","gram"], - ["application/srgs+xml","grxml"], - ["application/vnd.adobe.apollo-application-installer-package+zip","air"], - ["application/vnd.mif","mif"], - ["application/vnd.mozilla.xul+xml","xul"], - ["application/vnd.ms-excel","xls"], - ["application/vnd.ms-powerpoint","ppt"], - ["application/vnd.rn-realmedia","rm"], - ["application/vnd.wap.wbxml","wbxml"], - ["application/vnd.wap.wmlc","wmlc"], - ["application/vnd.wap.wmlscriptc","wmlsc"], - ["application/voicexml+xml","vxml"], - ["application/x-bcpio","bcpio"], - ["application/x-cdlink","vcd"], - ["application/x-chess-pgn","pgn"], - ["application/x-cpio","cpio"], - ["application/x-csh","csh"], - ["application/x-director","dcr","dir","dxr"], - ["application/x-dvi","dvi"], - ["application/x-futuresplash","spl"], - ["application/x-gtar","gtar"], - ["application/x-hdf","hdf"], - ["application/x-javascript","js"], - ["application/x-koan","skp","skd","skt","skm"], - ["application/x-latex","latex"], - ["application/x-netcdf","nc","cdf"], - ["application/x-sh","sh"], - ["application/x-shar","shar"], - ["application/x-shockwave-flash","swf"], - ["application/x-stuffit","sit"], - ["application/x-sv4cpio","sv4cpio"], - ["application/x-sv4crc","sv4crc"], - ["application/x-tar","tar"], - ["application/x-tcl","tcl"], - ["application/x-tex","tex"], - ["application/x-texinfo","texinfo","texi"], - ["application/x-troff","t","tr","roff"], - ["application/x-troff-man","man"], - ["application/x-troff-me","me"], - ["application/x-troff-ms","ms"], - ["application/x-ustar","ustar"], - ["application/x-wais-source","src"], - ["application/xhtml+xml","xhtml","xht"], - ["application/xml","xml","xsl"], - ["application/xml-dtd","dtd"], - ["application/xslt+xml","xslt"], - ["application/zip","zip"], - ["audio/basic","au","snd"], - ["audio/midi","mid","midi","kar"], - ["audio/mpeg","mp3","mpga","mp2"], - ["audio/x-aiff","aif","aiff","aifc"], - ["audio/x-mpegurl","m3u"], - ["audio/x-pn-realaudio","ram","ra"], - ["audio/x-wav","wav"], - ["chemical/x-pdb","pdb"], - ["chemical/x-xyz","xyz"], - ["image/bmp","bmp"], - ["image/cgm","cgm"], - ["image/gif","gif"], - ["image/ief","ief"], - ["image/jpeg","jpg","jpeg","jpe"], - ["image/png","png"], - ["image/svg+xml","svg"], - ["image/tiff","tiff","tif"], - ["image/vnd.djvu","djvu","djv"], - ["image/vnd.wap.wbmp","wbmp"], - ["image/x-cmu-raster","ras"], - ["image/x-icon","ico"], - ["image/x-portable-anymap","pnm"], - ["image/x-portable-bitmap","pbm"], - ["image/x-portable-graymap","pgm"], - ["image/x-portable-pixmap","ppm"], - ["image/x-rgb","rgb"], - ["image/x-xbitmap","xbm"], - ["image/x-xpixmap","xpm"], - ["image/x-xwindowdump","xwd"], - ["model/iges","igs","iges"], - ["model/mesh","msh","mesh","silo"], - ["model/vrml","wrl","vrml"], - ["text/calendar","ics","ifb"], - ["text/css","css"], - ["text/html","html","htm"], - ["text/plain","txt","asc"], - ["text/richtext","rtx"], - ["text/rtf","rtf"], - ["text/sgml","sgml","sgm"], - ["text/tab-separated-values","tsv"], - ["text/vnd.wap.wml","wml"], - ["text/vnd.wap.wmlscript","wmls"], - ["text/x-setext","etx"], - ["video/mpeg","mpg","mpeg","mpe"], - ["video/quicktime","mov","qt"], - ["video/vnd.mpegurl","m4u","mxu"], - ["video/x-flv","flv"], - ["video/x-msvideo","avi"], - ["video/x-sgi-movie","movie"], - ["x-conference/x-cooltalk","ice"]]; - - /** - * Returns the mimetype for the given extension. - */ - public function getMimeType(extension:String):String - { - extension = extension.toLocaleLowerCase(); - for each (var a:Array in types) - { - for each (var b:String in a) - { - if (b == extension) - { - return a[0]; - } - } - } - return null; - } - - /** - * Returns the prefered extension for the given mimetype. - */ - public function getExtension(mimetype:String):String - { - mimetype = mimetype.toLocaleLowerCase(); - for each (var a:Array in types) - { - if (a[0] == mimetype) - { - return a[1]; - } - } - return null; - } - - /** - * Adds a mimetype to the map. The order of the extensions matters. The most preferred should come first. - */ - public function addMimeType(mimetype:String, extensions:Array):void - { - var newType:Array = [mimetype]; - for each (var a:String in extensions) - { - newType.push(a); - } - types.push(newType); - } - } +/* + 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.net +{ + public class MimeTypeMap + { + private var types:Array = + [["application/andrew-inset","ez"], + ["application/atom+xml","atom"], + ["application/mac-binhex40","hqx"], + ["application/mac-compactpro","cpt"], + ["application/mathml+xml","mathml"], + ["application/msword","doc"], + ["application/octet-stream","bin","dms","lha","lzh","exe","class","so","dll","dmg"], + ["application/oda","oda"], + ["application/ogg","ogg"], + ["application/pdf","pdf"], + ["application/postscript","ai","eps","ps"], + ["application/rdf+xml","rdf"], + ["application/smil","smi","smil"], + ["application/srgs","gram"], + ["application/srgs+xml","grxml"], + ["application/vnd.adobe.apollo-application-installer-package+zip","air"], + ["application/vnd.mif","mif"], + ["application/vnd.mozilla.xul+xml","xul"], + ["application/vnd.ms-excel","xls"], + ["application/vnd.ms-powerpoint","ppt"], + ["application/vnd.rn-realmedia","rm"], + ["application/vnd.wap.wbxml","wbxml"], + ["application/vnd.wap.wmlc","wmlc"], + ["application/vnd.wap.wmlscriptc","wmlsc"], + ["application/voicexml+xml","vxml"], + ["application/x-bcpio","bcpio"], + ["application/x-cdlink","vcd"], + ["application/x-chess-pgn","pgn"], + ["application/x-cpio","cpio"], + ["application/x-csh","csh"], + ["application/x-director","dcr","dir","dxr"], + ["application/x-dvi","dvi"], + ["application/x-futuresplash","spl"], + ["application/x-gtar","gtar"], + ["application/x-hdf","hdf"], + ["application/x-javascript","js"], + ["application/x-koan","skp","skd","skt","skm"], + ["application/x-latex","latex"], + ["application/x-netcdf","nc","cdf"], + ["application/x-sh","sh"], + ["application/x-shar","shar"], + ["application/x-shockwave-flash","swf"], + ["application/x-stuffit","sit"], + ["application/x-sv4cpio","sv4cpio"], + ["application/x-sv4crc","sv4crc"], + ["application/x-tar","tar"], + ["application/x-tcl","tcl"], + ["application/x-tex","tex"], + ["application/x-texinfo","texinfo","texi"], + ["application/x-troff","t","tr","roff"], + ["application/x-troff-man","man"], + ["application/x-troff-me","me"], + ["application/x-troff-ms","ms"], + ["application/x-ustar","ustar"], + ["application/x-wais-source","src"], + ["application/xhtml+xml","xhtml","xht"], + ["application/xml","xml","xsl"], + ["application/xml-dtd","dtd"], + ["application/xslt+xml","xslt"], + ["application/zip","zip"], + ["audio/basic","au","snd"], + ["audio/midi","mid","midi","kar"], + ["audio/mpeg","mp3","mpga","mp2"], + ["audio/x-aiff","aif","aiff","aifc"], + ["audio/x-mpegurl","m3u"], + ["audio/x-pn-realaudio","ram","ra"], + ["audio/x-wav","wav"], + ["chemical/x-pdb","pdb"], + ["chemical/x-xyz","xyz"], + ["image/bmp","bmp"], + ["image/cgm","cgm"], + ["image/gif","gif"], + ["image/ief","ief"], + ["image/jpeg","jpg","jpeg","jpe"], + ["image/png","png"], + ["image/svg+xml","svg"], + ["image/tiff","tiff","tif"], + ["image/vnd.djvu","djvu","djv"], + ["image/vnd.wap.wbmp","wbmp"], + ["image/x-cmu-raster","ras"], + ["image/x-icon","ico"], + ["image/x-portable-anymap","pnm"], + ["image/x-portable-bitmap","pbm"], + ["image/x-portable-graymap","pgm"], + ["image/x-portable-pixmap","ppm"], + ["image/x-rgb","rgb"], + ["image/x-xbitmap","xbm"], + ["image/x-xpixmap","xpm"], + ["image/x-xwindowdump","xwd"], + ["model/iges","igs","iges"], + ["model/mesh","msh","mesh","silo"], + ["model/vrml","wrl","vrml"], + ["text/calendar","ics","ifb"], + ["text/css","css"], + ["text/html","html","htm"], + ["text/plain","txt","asc"], + ["text/richtext","rtx"], + ["text/rtf","rtf"], + ["text/sgml","sgml","sgm"], + ["text/tab-separated-values","tsv"], + ["text/vnd.wap.wml","wml"], + ["text/vnd.wap.wmlscript","wmls"], + ["text/x-setext","etx"], + ["video/mpeg","mpg","mpeg","mpe"], + ["video/quicktime","mov","qt"], + ["video/vnd.mpegurl","m4u","mxu"], + ["video/x-flv","flv"], + ["video/x-msvideo","avi"], + ["video/x-sgi-movie","movie"], + ["x-conference/x-cooltalk","ice"]]; + + /** + * Returns the mimetype for the given extension. + */ + public function getMimeType(extension:String):String + { + extension = extension.toLocaleLowerCase(); + for each (var a:Array in types) + { + for each (var b:String in a) + { + if (b == extension) + { + return a[0]; + } + } + } + return null; + } + + /** + * Returns the prefered extension for the given mimetype. + */ + public function getExtension(mimetype:String):String + { + mimetype = mimetype.toLocaleLowerCase(); + for each (var a:Array in types) + { + if (a[0] == mimetype) + { + return a[1]; + } + } + return null; + } + + /** + * Adds a mimetype to the map. The order of the extensions matters. The most preferred should come first. + */ + public function addMimeType(mimetype:String, extensions:Array):void + { + var newType:Array = [mimetype]; + for each (var a:String in extensions) + { + newType.push(a); + } + types.push(newType); + } + } } \ No newline at end of file diff --git a/src/com/adobe/net/URI.as b/src/com/adobe/net/URI.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/net/URIEncodingBitmap.as b/src/com/adobe/net/URIEncodingBitmap.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/net/proxies/RFC2817Socket.as b/src/com/adobe/net/proxies/RFC2817Socket.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/serialization/json/JSON.as b/src/com/adobe/serialization/json/JSON.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/serialization/json/JSONDecoder.as b/src/com/adobe/serialization/json/JSONDecoder.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/serialization/json/JSONEncoder.as b/src/com/adobe/serialization/json/JSONEncoder.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/serialization/json/JSONParseError.as b/src/com/adobe/serialization/json/JSONParseError.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/serialization/json/JSONToken.as b/src/com/adobe/serialization/json/JSONToken.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/serialization/json/JSONTokenType.as b/src/com/adobe/serialization/json/JSONTokenType.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/serialization/json/JSONTokenizer.as b/src/com/adobe/serialization/json/JSONTokenizer.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/utils/ArrayUtil.as b/src/com/adobe/utils/ArrayUtil.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/utils/DateUtil.as b/src/com/adobe/utils/DateUtil.as old mode 100644 new mode 100755 index a49fe43..9dae7e8 --- a/src/com/adobe/utils/DateUtil.as +++ b/src/com/adobe/utils/DateUtil.as @@ -1,699 +1,699 @@ -/* - 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.utils -{ - import mx.formatters.DateBase; - - /** - * Class that contains static utility methods for manipulating and working - * with Dates. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public class DateUtil - { - - /** - * Returns the English Short Month name (3 letters) for the Month that - * the Date represents. - * - * @param d The Date instance whose month will be used to retrieve the - * short month name. - * - * @return An English 3 Letter Month abbreviation. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see SHORT_MONTH - */ - public static function getShortMonthName(d:Date):String - { - return DateBase.monthNamesShort[d.getMonth()]; - } - - /** - * Returns the index of the month that the short month name string - * represents. - * - * @param m The 3 letter abbreviation representing a short month name. - * - * @param Optional parameter indicating whether the search should be case - * sensitive - * - * @return A int that represents that month represented by the specifed - * short name. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see SHORT_MONTH - */ - public static function getShortMonthIndex(m:String):int - { - return DateBase.monthNamesShort.indexOf(m); - } - - /** - * Returns the English full Month name for the Month that - * the Date represents. - * - * @param d The Date instance whose month will be used to retrieve the - * full month name. - * - * @return An English full month name. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see FULL_MONTH - */ - public static function getFullMonthName(d:Date):String - { - return DateBase.monthNamesLong[d.getMonth()]; - } - - /** - * Returns the index of the month that the full month name string - * represents. - * - * @param m A full month name. - * - * @return A int that represents that month represented by the specifed - * full month name. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see FULL_MONTH - */ - public static function getFullMonthIndex(m:String):int - { - return DateBase.monthNamesLong.indexOf(m); - } - - /** - * Returns the English Short Day name (3 letters) for the day that - * the Date represents. - * - * @param d The Date instance whose day will be used to retrieve the - * short day name. - * - * @return An English 3 Letter day abbreviation. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see SHORT_DAY - */ - public static function getShortDayName(d:Date):String - { - return DateBase.dayNamesShort[d.getDay()]; - } - - /** - * Returns the index of the day that the short day name string - * represents. - * - * @param m A short day name. - * - * @return A int that represents that short day represented by the specifed - * full month name. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see SHORT_DAY - */ - public static function getShortDayIndex(d:String):int - { - return DateBase.dayNamesShort.indexOf(d); - } - - /** - * Returns the English full day name for the day that - * the Date represents. - * - * @param d The Date instance whose day will be used to retrieve the - * full day name. - * - * @return An English full day name. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see FULL_DAY - */ - public static function getFullDayName(d:Date):String - { - return DateBase.dayNamesLong[d.getDay()]; - } - - /** - * Returns the index of the day that the full day name string - * represents. - * - * @param m A full day name. - * - * @return A int that represents that full day represented by the specifed - * full month name. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see FULL_DAY - */ - public static function getFullDayIndex(d:String):int - { - return DateBase.dayNamesLong.indexOf(d); - } - - /** - * Returns a two digit representation of the year represented by the - * specified date. - * - * @param d The Date instance whose year will be used to generate a two - * digit string representation of the year. - * - * @return A string that contains a 2 digit representation of the year. - * Single digits will be padded with 0. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function getShortYear(d:Date):String - { - var dStr:String = String(d.getFullYear()); - - if(dStr.length < 3) - { - return dStr; - } - - return (dStr.substr(dStr.length - 2)); - } - - /** - * Compares two dates and returns an integer depending on their relationship. - * - * Returns -1 if d1 is greater than d2. - * Returns 1 if d2 is greater than d1. - * Returns 0 if both dates are equal. - * - * @param d1 The date that will be compared to the second date. - * @param d2 The date that will be compared to the first date. - * - * @return An int indicating how the two dates compare. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function compareDates(d1:Date, d2:Date):int - { - var d1ms:Number = d1.getTime(); - var d2ms:Number = d2.getTime(); - - if(d1ms > d2ms) - { - return -1; - } - else if(d1ms < d2ms) - { - return 1; - } - else - { - return 0; - } - } - - /** - * Returns a short hour (0 - 12) represented by the specified date. - * - * If the hour is less than 12 (0 - 11 AM) then the hour will be returned. - * - * If the hour is greater than 12 (12 - 23 PM) then the hour minus 12 - * will be returned. - * - * @param d1 The Date from which to generate the short hour - * - * @return An int between 0 and 13 ( 1 - 12 ) representing the short hour. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function getShortHour(d:Date):int - { - var h:int = d.hours; - - if(h == 0 || h == 12) - { - return 12; - } - else if(h > 12) - { - return h - 12; - } - else - { - return h; - } - } - - /** - * Returns a string indicating whether the date represents a time in the - * ante meridiem (AM) or post meridiem (PM). - * - * If the hour is less than 12 then "AM" will be returned. - * - * If the hour is greater than 12 then "PM" will be returned. - * - * @param d1 The Date from which to generate the 12 hour clock indicator. - * - * @return A String ("AM" or "PM") indicating which half of the day the - * hour represents. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function getAMPM(d:Date):String - { - return (d.hours > 11)? "PM" : "AM"; - } - - /** - * Parses dates that conform to RFC822 into Date objects. This method also - * supports four-digit years (not supported in RFC822), but two-digit years - * (referring to the 20th century) are fine, too. - * - * This function is useful for parsing RSS .91, .92, and 2.0 dates. - * - * @param str - * - * @returns - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see http://asg.web.cmu.edu/rfc/rfc822.html - */ - public static function parseRFC822(str:String):Date - { - var finalDate:Date; - try - { - var dateParts:Array = str.split(" "); - var day:String = null; - - if (dateParts[0].search(/\d/) == -1) - { - day = dateParts.shift().replace(/\W/, ""); - } - - var date:Number = Number(dateParts.shift()); - var month:Number = Number(DateUtil.getShortMonthIndex(dateParts.shift())); - var year:Number = Number(dateParts.shift()); - var timeParts:Array = dateParts.shift().split(":"); - var hour:Number = int(timeParts.shift()); - var minute:Number = int(timeParts.shift()); - var second:Number = (timeParts.length > 0) ? int(timeParts.shift()): 0; - - var milliseconds:Number = Date.UTC(year, month, date, hour, minute, second, 0); - - var timezone:String = dateParts.shift(); - var offset:Number = 0; - - if (timezone.search(/\d/) == -1) - { - switch(timezone) - { - case "UT": - offset = 0; - break; - case "UTC": - offset = 0; - break; - case "GMT": - offset = 0; - break; - case "EST": - offset = (-5 * 3600000); - break; - case "EDT": - offset = (-4 * 3600000); - break; - case "CST": - offset = (-6 * 3600000); - break; - case "CDT": - offset = (-5 * 3600000); - break; - case "MST": - offset = (-7 * 3600000); - break; - case "MDT": - offset = (-6 * 3600000); - break; - case "PST": - offset = (-8 * 3600000); - break; - case "PDT": - offset = (-7 * 3600000); - break; - case "Z": - offset = 0; - break; - case "A": - offset = (-1 * 3600000); - break; - case "M": - offset = (-12 * 3600000); - break; - case "N": - offset = (1 * 3600000); - break; - case "Y": - offset = (12 * 3600000); - break; - default: - offset = 0; - } - } - else - { - var multiplier:Number = 1; - var oHours:Number = 0; - var oMinutes:Number = 0; - if (timezone.length != 4) - { - if (timezone.charAt(0) == "-") - { - multiplier = -1; - } - timezone = timezone.substr(1, 4); - } - oHours = Number(timezone.substr(0, 2)); - oMinutes = Number(timezone.substr(2, 2)); - offset = (((oHours * 3600000) + (oMinutes * 60000)) * multiplier); - } - - finalDate = new Date(milliseconds - offset); - - if (finalDate.toString() == "Invalid Date") - { - throw new Error("This date does not conform to RFC822."); - } - } - catch (e:Error) - { - var eStr:String = "Unable to parse the string [" +str+ "] into a date. "; - eStr += "The internal error was: " + e.toString(); - throw new Error(eStr); - } - return finalDate; - } - - /** - * Returns a date string formatted according to RFC822. - * - * @param d - * - * @returns - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see http://asg.web.cmu.edu/rfc/rfc822.html - */ - public static function toRFC822(d:Date):String - { - var date:Number = d.getUTCDate(); - var hours:Number = d.getUTCHours(); - var minutes:Number = d.getUTCMinutes(); - var seconds:Number = d.getUTCSeconds(); - var sb:String = new String(); - sb += DateBase.dayNamesShort[d.getUTCDay()]; - sb += ", "; - - if (date < 10) - { - sb += "0"; - } - sb += date; - sb += " "; - //sb += DateUtil.SHORT_MONTH[d.getUTCMonth()]; - sb += DateBase.monthNamesShort[d.getUTCMonth()]; - sb += " "; - sb += d.getUTCFullYear(); - sb += " "; - if (hours < 10) - { - sb += "0"; - } - sb += hours; - sb += ":"; - if (minutes < 10) - { - sb += "0"; - } - sb += minutes; - sb += ":"; - if (seconds < 10) - { - sb += "0"; - } - sb += seconds; - sb += " GMT"; - return sb; - } - - /** - * Parses dates that conform to the W3C Date-time Format into Date objects. - * - * This function is useful for parsing RSS 1.0 and Atom 1.0 dates. - * - * @param str - * - * @returns - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see http://www.w3.org/TR/NOTE-datetime - */ - public static function parseW3CDTF(str:String):Date - { - var finalDate:Date; - try - { - var dateStr:String = str.substring(0, str.indexOf("T")); - var timeStr:String = str.substring(str.indexOf("T")+1, str.length); - var dateArr:Array = dateStr.split("-"); - var year:Number = Number(dateArr.shift()); - var month:Number = Number(dateArr.shift()); - var date:Number = Number(dateArr.shift()); - - var multiplier:Number; - var offsetHours:Number; - var offsetMinutes:Number; - var offsetStr:String; - - if (timeStr.indexOf("Z") != -1) - { - multiplier = 1; - offsetHours = 0; - offsetMinutes = 0; - timeStr = timeStr.replace("Z", ""); - } - else if (timeStr.indexOf("+") != -1) - { - multiplier = 1; - offsetStr = timeStr.substring(timeStr.indexOf("+")+1, timeStr.length); - offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":"))); - offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1, offsetStr.length)); - timeStr = timeStr.substring(0, timeStr.indexOf("+")); - } - else // offset is - - { - multiplier = -1; - offsetStr = timeStr.substring(timeStr.indexOf("-")+1, timeStr.length); - offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":"))); - offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1, offsetStr.length)); - timeStr = timeStr.substring(0, timeStr.indexOf("-")); - } - var timeArr:Array = timeStr.split(":"); - var hour:Number = Number(timeArr.shift()); - var minutes:Number = Number(timeArr.shift()); - var secondsArr:Array = (timeArr.length > 0) ? String(timeArr.shift()).split(".") : null; - var seconds:Number = (secondsArr != null && secondsArr.length > 0) ? Number(secondsArr.shift()) : 0; - var milliseconds:Number = (secondsArr != null && secondsArr.length > 0) ? Number(secondsArr.shift()) : 0; - var utc:Number = Date.UTC(year, month-1, date, hour, minutes, seconds, milliseconds); - var offset:Number = (((offsetHours * 3600000) + (offsetMinutes * 60000)) * multiplier); - finalDate = new Date(utc - offset); - - if (finalDate.toString() == "Invalid Date") - { - throw new Error("This date does not conform to W3CDTF."); - } - } - catch (e:Error) - { - var eStr:String = "Unable to parse the string [" +str+ "] into a date. "; - eStr += "The internal error was: " + e.toString(); - throw new Error(eStr); - } - return finalDate; - } - - /** - * Returns a date string formatted according to W3CDTF. - * - * @param d - * @param includeMilliseconds Determines whether to include the - * milliseconds value (if any) in the formatted string. - * - * @returns - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - * - * @see http://www.w3.org/TR/NOTE-datetime - */ - public static function toW3CDTF(d:Date,includeMilliseconds:Boolean=false):String - { - var date:Number = d.getUTCDate(); - var month:Number = d.getUTCMonth(); - var hours:Number = d.getUTCHours(); - var minutes:Number = d.getUTCMinutes(); - var seconds:Number = d.getUTCSeconds(); - var milliseconds:Number = d.getUTCMilliseconds(); - var sb:String = new String(); - - sb += d.getUTCFullYear(); - sb += "-"; - - //thanks to "dom" who sent in a fix for the line below - if (month + 1 < 10) - { - sb += "0"; - } - sb += month + 1; - sb += "-"; - if (date < 10) - { - sb += "0"; - } - sb += date; - sb += "T"; - if (hours < 10) - { - sb += "0"; - } - sb += hours; - sb += ":"; - if (minutes < 10) - { - sb += "0"; - } - sb += minutes; - sb += ":"; - if (seconds < 10) - { - sb += "0"; - } - sb += seconds; - if (includeMilliseconds && milliseconds > 0) - { - sb += "."; - sb += milliseconds; - } - sb += "-00:00"; - return sb; - } - - /** - * Converts a date into just after midnight. - */ - public static function makeMorning(d:Date):Date - { - var d:Date = new Date(d.time); - d.hours = 0; - d.minutes = 0; - d.seconds = 0; - d.milliseconds = 0; - return d; - } - - /** - * Converts a date into just befor midnight. - */ - public static function makeNight(d:Date):Date - { - var d:Date = new Date(d.time); - d.hours = 23; - d.minutes = 59; - d.seconds = 59; - d.milliseconds = 999; - return d; - } - - /** - * Sort of converts a date into UTC. - */ - public static function getUTCDate(d:Date):Date - { - var nd:Date = new Date(); - var offset:Number = d.getTimezoneOffset() * 60 * 1000; - nd.setTime(d.getTime() + offset); - return nd; - } - } -} +/* + 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.utils +{ + import mx.formatters.DateBase; + + /** + * Class that contains static utility methods for manipulating and working + * with Dates. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public class DateUtil + { + + /** + * Returns the English Short Month name (3 letters) for the Month that + * the Date represents. + * + * @param d The Date instance whose month will be used to retrieve the + * short month name. + * + * @return An English 3 Letter Month abbreviation. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see SHORT_MONTH + */ + public static function getShortMonthName(d:Date):String + { + return DateBase.monthNamesShort[d.getMonth()]; + } + + /** + * Returns the index of the month that the short month name string + * represents. + * + * @param m The 3 letter abbreviation representing a short month name. + * + * @param Optional parameter indicating whether the search should be case + * sensitive + * + * @return A int that represents that month represented by the specifed + * short name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see SHORT_MONTH + */ + public static function getShortMonthIndex(m:String):int + { + return DateBase.monthNamesShort.indexOf(m); + } + + /** + * Returns the English full Month name for the Month that + * the Date represents. + * + * @param d The Date instance whose month will be used to retrieve the + * full month name. + * + * @return An English full month name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see FULL_MONTH + */ + public static function getFullMonthName(d:Date):String + { + return DateBase.monthNamesLong[d.getMonth()]; + } + + /** + * Returns the index of the month that the full month name string + * represents. + * + * @param m A full month name. + * + * @return A int that represents that month represented by the specifed + * full month name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see FULL_MONTH + */ + public static function getFullMonthIndex(m:String):int + { + return DateBase.monthNamesLong.indexOf(m); + } + + /** + * Returns the English Short Day name (3 letters) for the day that + * the Date represents. + * + * @param d The Date instance whose day will be used to retrieve the + * short day name. + * + * @return An English 3 Letter day abbreviation. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see SHORT_DAY + */ + public static function getShortDayName(d:Date):String + { + return DateBase.dayNamesShort[d.getDay()]; + } + + /** + * Returns the index of the day that the short day name string + * represents. + * + * @param m A short day name. + * + * @return A int that represents that short day represented by the specifed + * full month name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see SHORT_DAY + */ + public static function getShortDayIndex(d:String):int + { + return DateBase.dayNamesShort.indexOf(d); + } + + /** + * Returns the English full day name for the day that + * the Date represents. + * + * @param d The Date instance whose day will be used to retrieve the + * full day name. + * + * @return An English full day name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see FULL_DAY + */ + public static function getFullDayName(d:Date):String + { + return DateBase.dayNamesLong[d.getDay()]; + } + + /** + * Returns the index of the day that the full day name string + * represents. + * + * @param m A full day name. + * + * @return A int that represents that full day represented by the specifed + * full month name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see FULL_DAY + */ + public static function getFullDayIndex(d:String):int + { + return DateBase.dayNamesLong.indexOf(d); + } + + /** + * Returns a two digit representation of the year represented by the + * specified date. + * + * @param d The Date instance whose year will be used to generate a two + * digit string representation of the year. + * + * @return A string that contains a 2 digit representation of the year. + * Single digits will be padded with 0. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function getShortYear(d:Date):String + { + var dStr:String = String(d.getFullYear()); + + if(dStr.length < 3) + { + return dStr; + } + + return (dStr.substr(dStr.length - 2)); + } + + /** + * Compares two dates and returns an integer depending on their relationship. + * + * Returns -1 if d1 is greater than d2. + * Returns 1 if d2 is greater than d1. + * Returns 0 if both dates are equal. + * + * @param d1 The date that will be compared to the second date. + * @param d2 The date that will be compared to the first date. + * + * @return An int indicating how the two dates compare. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function compareDates(d1:Date, d2:Date):int + { + var d1ms:Number = d1.getTime(); + var d2ms:Number = d2.getTime(); + + if(d1ms > d2ms) + { + return -1; + } + else if(d1ms < d2ms) + { + return 1; + } + else + { + return 0; + } + } + + /** + * Returns a short hour (0 - 12) represented by the specified date. + * + * If the hour is less than 12 (0 - 11 AM) then the hour will be returned. + * + * If the hour is greater than 12 (12 - 23 PM) then the hour minus 12 + * will be returned. + * + * @param d1 The Date from which to generate the short hour + * + * @return An int between 0 and 13 ( 1 - 12 ) representing the short hour. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function getShortHour(d:Date):int + { + var h:int = d.hours; + + if(h == 0 || h == 12) + { + return 12; + } + else if(h > 12) + { + return h - 12; + } + else + { + return h; + } + } + + /** + * Returns a string indicating whether the date represents a time in the + * ante meridiem (AM) or post meridiem (PM). + * + * If the hour is less than 12 then "AM" will be returned. + * + * If the hour is greater than 12 then "PM" will be returned. + * + * @param d1 The Date from which to generate the 12 hour clock indicator. + * + * @return A String ("AM" or "PM") indicating which half of the day the + * hour represents. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function getAMPM(d:Date):String + { + return (d.hours > 11)? "PM" : "AM"; + } + + /** + * Parses dates that conform to RFC822 into Date objects. This method also + * supports four-digit years (not supported in RFC822), but two-digit years + * (referring to the 20th century) are fine, too. + * + * This function is useful for parsing RSS .91, .92, and 2.0 dates. + * + * @param str + * + * @returns + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see http://asg.web.cmu.edu/rfc/rfc822.html + */ + public static function parseRFC822(str:String):Date + { + var finalDate:Date; + try + { + var dateParts:Array = str.split(" "); + var day:String = null; + + if (dateParts[0].search(/\d/) == -1) + { + day = dateParts.shift().replace(/\W/, ""); + } + + var date:Number = Number(dateParts.shift()); + var month:Number = Number(DateUtil.getShortMonthIndex(dateParts.shift())); + var year:Number = Number(dateParts.shift()); + var timeParts:Array = dateParts.shift().split(":"); + var hour:Number = int(timeParts.shift()); + var minute:Number = int(timeParts.shift()); + var second:Number = (timeParts.length > 0) ? int(timeParts.shift()): 0; + + var milliseconds:Number = Date.UTC(year, month, date, hour, minute, second, 0); + + var timezone:String = dateParts.shift(); + var offset:Number = 0; + + if (timezone.search(/\d/) == -1) + { + switch(timezone) + { + case "UT": + offset = 0; + break; + case "UTC": + offset = 0; + break; + case "GMT": + offset = 0; + break; + case "EST": + offset = (-5 * 3600000); + break; + case "EDT": + offset = (-4 * 3600000); + break; + case "CST": + offset = (-6 * 3600000); + break; + case "CDT": + offset = (-5 * 3600000); + break; + case "MST": + offset = (-7 * 3600000); + break; + case "MDT": + offset = (-6 * 3600000); + break; + case "PST": + offset = (-8 * 3600000); + break; + case "PDT": + offset = (-7 * 3600000); + break; + case "Z": + offset = 0; + break; + case "A": + offset = (-1 * 3600000); + break; + case "M": + offset = (-12 * 3600000); + break; + case "N": + offset = (1 * 3600000); + break; + case "Y": + offset = (12 * 3600000); + break; + default: + offset = 0; + } + } + else + { + var multiplier:Number = 1; + var oHours:Number = 0; + var oMinutes:Number = 0; + if (timezone.length != 4) + { + if (timezone.charAt(0) == "-") + { + multiplier = -1; + } + timezone = timezone.substr(1, 4); + } + oHours = Number(timezone.substr(0, 2)); + oMinutes = Number(timezone.substr(2, 2)); + offset = (((oHours * 3600000) + (oMinutes * 60000)) * multiplier); + } + + finalDate = new Date(milliseconds - offset); + + if (finalDate.toString() == "Invalid Date") + { + throw new Error("This date does not conform to RFC822."); + } + } + catch (e:Error) + { + var eStr:String = "Unable to parse the string [" +str+ "] into a date. "; + eStr += "The internal error was: " + e.toString(); + throw new Error(eStr); + } + return finalDate; + } + + /** + * Returns a date string formatted according to RFC822. + * + * @param d + * + * @returns + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see http://asg.web.cmu.edu/rfc/rfc822.html + */ + public static function toRFC822(d:Date):String + { + var date:Number = d.getUTCDate(); + var hours:Number = d.getUTCHours(); + var minutes:Number = d.getUTCMinutes(); + var seconds:Number = d.getUTCSeconds(); + var sb:String = new String(); + sb += DateBase.dayNamesShort[d.getUTCDay()]; + sb += ", "; + + if (date < 10) + { + sb += "0"; + } + sb += date; + sb += " "; + //sb += DateUtil.SHORT_MONTH[d.getUTCMonth()]; + sb += DateBase.monthNamesShort[d.getUTCMonth()]; + sb += " "; + sb += d.getUTCFullYear(); + sb += " "; + if (hours < 10) + { + sb += "0"; + } + sb += hours; + sb += ":"; + if (minutes < 10) + { + sb += "0"; + } + sb += minutes; + sb += ":"; + if (seconds < 10) + { + sb += "0"; + } + sb += seconds; + sb += " GMT"; + return sb; + } + + /** + * Parses dates that conform to the W3C Date-time Format into Date objects. + * + * This function is useful for parsing RSS 1.0 and Atom 1.0 dates. + * + * @param str + * + * @returns + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see http://www.w3.org/TR/NOTE-datetime + */ + public static function parseW3CDTF(str:String):Date + { + var finalDate:Date; + try + { + var dateStr:String = str.substring(0, str.indexOf("T")); + var timeStr:String = str.substring(str.indexOf("T")+1, str.length); + var dateArr:Array = dateStr.split("-"); + var year:Number = Number(dateArr.shift()); + var month:Number = Number(dateArr.shift()); + var date:Number = Number(dateArr.shift()); + + var multiplier:Number; + var offsetHours:Number; + var offsetMinutes:Number; + var offsetStr:String; + + if (timeStr.indexOf("Z") != -1) + { + multiplier = 1; + offsetHours = 0; + offsetMinutes = 0; + timeStr = timeStr.replace("Z", ""); + } + else if (timeStr.indexOf("+") != -1) + { + multiplier = 1; + offsetStr = timeStr.substring(timeStr.indexOf("+")+1, timeStr.length); + offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":"))); + offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1, offsetStr.length)); + timeStr = timeStr.substring(0, timeStr.indexOf("+")); + } + else // offset is - + { + multiplier = -1; + offsetStr = timeStr.substring(timeStr.indexOf("-")+1, timeStr.length); + offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":"))); + offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1, offsetStr.length)); + timeStr = timeStr.substring(0, timeStr.indexOf("-")); + } + var timeArr:Array = timeStr.split(":"); + var hour:Number = Number(timeArr.shift()); + var minutes:Number = Number(timeArr.shift()); + var secondsArr:Array = (timeArr.length > 0) ? String(timeArr.shift()).split(".") : null; + var seconds:Number = (secondsArr != null && secondsArr.length > 0) ? Number(secondsArr.shift()) : 0; + var milliseconds:Number = (secondsArr != null && secondsArr.length > 0) ? Number(secondsArr.shift()) : 0; + var utc:Number = Date.UTC(year, month-1, date, hour, minutes, seconds, milliseconds); + var offset:Number = (((offsetHours * 3600000) + (offsetMinutes * 60000)) * multiplier); + finalDate = new Date(utc - offset); + + if (finalDate.toString() == "Invalid Date") + { + throw new Error("This date does not conform to W3CDTF."); + } + } + catch (e:Error) + { + var eStr:String = "Unable to parse the string [" +str+ "] into a date. "; + eStr += "The internal error was: " + e.toString(); + throw new Error(eStr); + } + return finalDate; + } + + /** + * Returns a date string formatted according to W3CDTF. + * + * @param d + * @param includeMilliseconds Determines whether to include the + * milliseconds value (if any) in the formatted string. + * + * @returns + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see http://www.w3.org/TR/NOTE-datetime + */ + public static function toW3CDTF(d:Date,includeMilliseconds:Boolean=false):String + { + var date:Number = d.getUTCDate(); + var month:Number = d.getUTCMonth(); + var hours:Number = d.getUTCHours(); + var minutes:Number = d.getUTCMinutes(); + var seconds:Number = d.getUTCSeconds(); + var milliseconds:Number = d.getUTCMilliseconds(); + var sb:String = new String(); + + sb += d.getUTCFullYear(); + sb += "-"; + + //thanks to "dom" who sent in a fix for the line below + if (month + 1 < 10) + { + sb += "0"; + } + sb += month + 1; + sb += "-"; + if (date < 10) + { + sb += "0"; + } + sb += date; + sb += "T"; + if (hours < 10) + { + sb += "0"; + } + sb += hours; + sb += ":"; + if (minutes < 10) + { + sb += "0"; + } + sb += minutes; + sb += ":"; + if (seconds < 10) + { + sb += "0"; + } + sb += seconds; + if (includeMilliseconds && milliseconds > 0) + { + sb += "."; + sb += milliseconds; + } + sb += "-00:00"; + return sb; + } + + /** + * Converts a date into just after midnight. + */ + public static function makeMorning(d:Date):Date + { + var d:Date = new Date(d.time); + d.hours = 0; + d.minutes = 0; + d.seconds = 0; + d.milliseconds = 0; + return d; + } + + /** + * Converts a date into just befor midnight. + */ + public static function makeNight(d:Date):Date + { + var d:Date = new Date(d.time); + d.hours = 23; + d.minutes = 59; + d.seconds = 59; + d.milliseconds = 999; + return d; + } + + /** + * Sort of converts a date into UTC. + */ + public static function getUTCDate(d:Date):Date + { + var nd:Date = new Date(); + var offset:Number = d.getTimezoneOffset() * 60 * 1000; + nd.setTime(d.getTime() + offset); + return nd; + } + } +} diff --git a/src/com/adobe/utils/DictionaryUtil.as b/src/com/adobe/utils/DictionaryUtil.as old mode 100644 new mode 100755 index 9552ef4..3e9f1c4 --- a/src/com/adobe/utils/DictionaryUtil.as +++ b/src/com/adobe/utils/DictionaryUtil.as @@ -1,87 +1,87 @@ -/* - 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.utils -{ - import flash.utils.Dictionary; - - public class DictionaryUtil - { - - /** - * Returns an Array of all keys within the specified dictionary. - * - * @param d The Dictionary instance whose keys will be returned. - * - * @return Array of keys contained within the Dictionary - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function getKeys(d:Dictionary):Array - { - var a:Array = new Array(); - - for (var key:Object in d) - { - a.push(key); - } - - return a; - } - - /** - * Returns an Array of all values within the specified dictionary. - * - * @param d The Dictionary instance whose values will be returned. - * - * @return Array of values contained within the Dictionary - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function getValues(d:Dictionary):Array - { - var a:Array = new Array(); - - for each (var value:Object in d) - { - a.push(value); - } - - return a; - } - - } +/* + 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.utils +{ + import flash.utils.Dictionary; + + public class DictionaryUtil + { + + /** + * Returns an Array of all keys within the specified dictionary. + * + * @param d The Dictionary instance whose keys will be returned. + * + * @return Array of keys contained within the Dictionary + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function getKeys(d:Dictionary):Array + { + var a:Array = new Array(); + + for (var key:Object in d) + { + a.push(key); + } + + return a; + } + + /** + * Returns an Array of all values within the specified dictionary. + * + * @param d The Dictionary instance whose values will be returned. + * + * @return Array of values contained within the Dictionary + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function getValues(d:Dictionary):Array + { + var a:Array = new Array(); + + for each (var value:Object in d) + { + a.push(value); + } + + return a; + } + + } } \ No newline at end of file diff --git a/src/com/adobe/utils/IntUtil.as b/src/com/adobe/utils/IntUtil.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/utils/NumberFormatter.as b/src/com/adobe/utils/NumberFormatter.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/utils/StringUtil.as b/src/com/adobe/utils/StringUtil.as old mode 100644 new mode 100755 index 6aa1979..4f3a038 --- a/src/com/adobe/utils/StringUtil.as +++ b/src/com/adobe/utils/StringUtil.as @@ -1,270 +1,270 @@ -/* - 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.utils -{ - - /** - * Class that contains static utility methods for manipulating Strings. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public class StringUtil - { - - - /** - * Does a case insensitive compare or two strings and returns true if - * they are equal. - * - * @param s1 The first string to compare. - * - * @param s2 The second string to compare. - * - * @returns A boolean value indicating whether the strings' values are - * equal in a case sensitive compare. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function stringsAreEqual(s1:String, s2:String, - caseSensitive:Boolean):Boolean - { - if(caseSensitive) - { - return (s1 == s2); - } - else - { - return (s1.toUpperCase() == s2.toUpperCase()); - } - } - - /** - * Removes whitespace from the front and the end of the specified - * string. - * - * @param input The String whose beginning and ending whitespace will - * will be removed. - * - * @returns A String with whitespace removed from the begining and end - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function trim(input:String):String - { - return StringUtil.ltrim(StringUtil.rtrim(input)); - } - - /** - * Removes whitespace from the front of the specified string. - * - * @param input The String whose beginning whitespace will will be removed. - * - * @returns A String with whitespace removed from the begining - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function ltrim(input:String):String - { - var size:Number = input.length; - for(var i:Number = 0; i < size; i++) - { - if(input.charCodeAt(i) > 32) - { - return input.substring(i); - } - } - return ""; - } - - /** - * Removes whitespace from the end of the specified string. - * - * @param input The String whose ending whitespace will will be removed. - * - * @returns A String with whitespace removed from the end - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function rtrim(input:String):String - { - var size:Number = input.length; - for(var i:Number = size; i > 0; i--) - { - if(input.charCodeAt(i - 1) > 32) - { - return input.substring(0, i); - } - } - - return ""; - } - - /** - * Determines whether the specified string begins with the spcified prefix. - * - * @param input The string that the prefix will be checked against. - * - * @param prefix The prefix that will be tested against the string. - * - * @returns True if the string starts with the prefix, false if it does not. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function beginsWith(input:String, prefix:String):Boolean - { - return (prefix == input.substring(0, prefix.length)); - } - - /** - * Determines whether the specified string ends with the spcified suffix. - * - * @param input The string that the suffic will be checked against. - * - * @param prefix The suffic that will be tested against the string. - * - * @returns True if the string ends with the suffix, false if it does not. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function endsWith(input:String, suffix:String):Boolean - { - return (suffix == input.substring(input.length - suffix.length)); - } - - /** - * Removes all instances of the remove string in the input string. - * - * @param input The string that will be checked for instances of remove - * string - * - * @param remove The string that will be removed from the input string. - * - * @returns A String with the remove string removed. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function remove(input:String, remove:String):String - { - return StringUtil.replace(input, remove, ""); - } - - /** - * Replaces all instances of the replace string in the input string - * with the replaceWith string. - * - * @param input The string that instances of replace string will be - * replaces with removeWith string. - * - * @param replace The string that will be replaced by instances of - * the replaceWith string. - * - * @param replaceWith The string that will replace instances of replace - * string. - * - * @returns A new String with the replace string replaced with the - * replaceWith string. - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function replace(input:String, replace:String, replaceWith:String):String - { - //change to StringBuilder - var sb:String = new String(); - var found:Boolean = false; - - var sLen:Number = input.length; - var rLen:Number = replace.length; - - for (var i:Number = 0; i < sLen; i++) - { - if(input.charAt(i) == replace.charAt(0)) - { - found = true; - for(var j:Number = 0; j < rLen; j++) - { - if(!(input.charAt(i + j) == replace.charAt(j))) - { - found = false; - break; - } - } - - if(found) - { - sb += replaceWith; - i = i + (rLen - 1); - continue; - } - } - sb += input.charAt(i); - } - //TODO : if the string is not found, should we return the original - //string? - return sb; - } - - /** - * Specifies whether the specified string is either non-null, or contains - * characters (i.e. length is greater that 0) - * - * @param s The string which is being checked for a value - * - * @langversion ActionScript 3.0 - * @playerversion Flash 9.0 - * @tiptext - */ - public static function stringHasValue(s:String):Boolean - { - //todo: this needs a unit test - return (s != null && s.length > 0); - } - } +/* + 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.utils +{ + + /** + * Class that contains static utility methods for manipulating Strings. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public class StringUtil + { + + + /** + * Does a case insensitive compare or two strings and returns true if + * they are equal. + * + * @param s1 The first string to compare. + * + * @param s2 The second string to compare. + * + * @returns A boolean value indicating whether the strings' values are + * equal in a case sensitive compare. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function stringsAreEqual(s1:String, s2:String, + caseSensitive:Boolean):Boolean + { + if(caseSensitive) + { + return (s1 == s2); + } + else + { + return (s1.toUpperCase() == s2.toUpperCase()); + } + } + + /** + * Removes whitespace from the front and the end of the specified + * string. + * + * @param input The String whose beginning and ending whitespace will + * will be removed. + * + * @returns A String with whitespace removed from the begining and end + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function trim(input:String):String + { + return StringUtil.ltrim(StringUtil.rtrim(input)); + } + + /** + * Removes whitespace from the front of the specified string. + * + * @param input The String whose beginning whitespace will will be removed. + * + * @returns A String with whitespace removed from the begining + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function ltrim(input:String):String + { + var size:Number = input.length; + for(var i:Number = 0; i < size; i++) + { + if(input.charCodeAt(i) > 32) + { + return input.substring(i); + } + } + return ""; + } + + /** + * Removes whitespace from the end of the specified string. + * + * @param input The String whose ending whitespace will will be removed. + * + * @returns A String with whitespace removed from the end + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function rtrim(input:String):String + { + var size:Number = input.length; + for(var i:Number = size; i > 0; i--) + { + if(input.charCodeAt(i - 1) > 32) + { + return input.substring(0, i); + } + } + + return ""; + } + + /** + * Determines whether the specified string begins with the spcified prefix. + * + * @param input The string that the prefix will be checked against. + * + * @param prefix The prefix that will be tested against the string. + * + * @returns True if the string starts with the prefix, false if it does not. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function beginsWith(input:String, prefix:String):Boolean + { + return (prefix == input.substring(0, prefix.length)); + } + + /** + * Determines whether the specified string ends with the spcified suffix. + * + * @param input The string that the suffic will be checked against. + * + * @param prefix The suffic that will be tested against the string. + * + * @returns True if the string ends with the suffix, false if it does not. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function endsWith(input:String, suffix:String):Boolean + { + return (suffix == input.substring(input.length - suffix.length)); + } + + /** + * Removes all instances of the remove string in the input string. + * + * @param input The string that will be checked for instances of remove + * string + * + * @param remove The string that will be removed from the input string. + * + * @returns A String with the remove string removed. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function remove(input:String, remove:String):String + { + return StringUtil.replace(input, remove, ""); + } + + /** + * Replaces all instances of the replace string in the input string + * with the replaceWith string. + * + * @param input The string that instances of replace string will be + * replaces with removeWith string. + * + * @param replace The string that will be replaced by instances of + * the replaceWith string. + * + * @param replaceWith The string that will replace instances of replace + * string. + * + * @returns A new String with the replace string replaced with the + * replaceWith string. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function replace(input:String, replace:String, replaceWith:String):String + { + //change to StringBuilder + var sb:String = new String(); + var found:Boolean = false; + + var sLen:Number = input.length; + var rLen:Number = replace.length; + + for (var i:Number = 0; i < sLen; i++) + { + if(input.charAt(i) == replace.charAt(0)) + { + found = true; + for(var j:Number = 0; j < rLen; j++) + { + if(!(input.charAt(i + j) == replace.charAt(j))) + { + found = false; + break; + } + } + + if(found) + { + sb += replaceWith; + i = i + (rLen - 1); + continue; + } + } + sb += input.charAt(i); + } + //TODO : if the string is not found, should we return the original + //string? + return sb; + } + + /** + * Specifies whether the specified string is either non-null, or contains + * characters (i.e. length is greater that 0) + * + * @param s The string which is being checked for a value + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function stringHasValue(s:String):Boolean + { + //todo: this needs a unit test + return (s != null && s.length > 0); + } + } } \ No newline at end of file diff --git a/src/com/adobe/utils/XMLUtil.as b/src/com/adobe/utils/XMLUtil.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/webapis/ServiceBase.as b/src/com/adobe/webapis/ServiceBase.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/webapis/URLLoaderBase.as b/src/com/adobe/webapis/URLLoaderBase.as old mode 100644 new mode 100755 diff --git a/src/com/adobe/webapis/events/ServiceEvent.as b/src/com/adobe/webapis/events/ServiceEvent.as old mode 100644 new mode 100755 diff --git a/src/org/flex_pilot/FPAssert.as b/src/org/flex_pilot/FPAssert.as index e3bc0c6..7a5596d 100644 --- a/src/org/flex_pilot/FPAssert.as +++ b/src/org/flex_pilot/FPAssert.as @@ -235,6 +235,10 @@ package org.flex_pilot { } } } + // Do any preprocessing of the value to check + if (opts.preMatchProcess) { + attrVal = opts.preMatchProcess(attrVal); + } } // Attr name is passed as part of the validator using // the pipe syntax: @@ -271,16 +275,11 @@ package org.flex_pilot { } } - // Do any preprocessing of the value to check - if (opts.preMatchProcess) { - attrVal = opts.preMatchProcess(attrVal); - } - // Check for a match var ret:Boolean = false; var errMsg:String; if (matchType == FPAssert.matchTypes.EXACT) { - ret = attrVal == expectedVal; + ret = String(attrVal) === expectedVal; errMsg = 'Expected "' + expectedVal + '", got "' + attrVal + '"'; } else if (matchType == FPAssert.matchTypes.CONTAINS) { diff --git a/src/org/flex_pilot/FPBootstrap.as b/src/org/flex_pilot/FPBootstrap.as index 4426e52..17ab444 100644 --- a/src/org/flex_pilot/FPBootstrap.as +++ b/src/org/flex_pilot/FPBootstrap.as @@ -21,24 +21,39 @@ package org.flex_pilot { import flash.system.ApplicationDomain; import flash.system.SecurityDomain; import flash.system.LoaderContext; + public class FPBootstrap { - public static var flex_pilotLibPath:String = '/flash/org/flex_pilot/FlexPilot.swf'; + public static var flex_pilotLibPath:String = 'FlexPilot.swf'; public static var wm:*; public static function init(context:*, domains:* = null):void { var loader:Loader = new Loader(); var url:String = FPBootstrap.flex_pilotLibPath; var req:URLRequest = new URLRequest(url); + + //FlexPilot.init({ context: context, domains: domains }); + + + var con:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, SecurityDomain.currentDomain); + + loader.contentLoaderInfo.addEventListener( Event.COMPLETE, function ():void { + + + + wm = ApplicationDomain.currentDomain.getDefinition( "org.flex_pilot.FlexPilot") as Class; wm.init({ context: context, domains: domains }); + }); + loader.load(req, con); + } } } diff --git a/src/org/flex_pilot/FPController.as b/src/org/flex_pilot/FPController.as index 6cedf8d..3035120 100644 --- a/src/org/flex_pilot/FPController.as +++ b/src/org/flex_pilot/FPController.as @@ -15,17 +15,28 @@ Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. */ package org.flex_pilot { - import org.flex_pilot.events.*; - import org.flex_pilot.FPLocator; - import flash.events.* - import mx.events.* - import flash.utils.*; + import flash.events.*; import flash.geom.Point; + import flash.ui.Mouse; + import flash.utils.*; + import flash.display.DisplayObjectContainer; + import flash.display.DisplayObject; + + import mx.controls.DataGrid; + import mx.events.*; + + import org.flex_pilot.FPLocator; + import org.flex_pilot.events.*; + + FP::complete { + import mx.controls.AdvancedDataGrid; + } public class FPController { + public function FPController():void {} - public static function mouseOver(params:Object):void { + public static function mouseOver(params:Object):void { var obj:* = FPLocator.lookupDisplayObject(params); Events.triggerMouseEvent(obj, MouseEvent.MOUSE_OVER); Events.triggerMouseEvent(obj, MouseEvent.ROLL_OVER); @@ -39,14 +50,14 @@ package org.flex_pilot { public static function click(params:Object):void { var obj:* = FPLocator.lookupDisplayObject(params); - + //Figure out what kind of displayObj were dealing with var classInfo:XML = describeType(obj); classInfo = describeType(obj); var objType:String = classInfo.@name.toString(); - function doTheClick(obj:*):void { - // Give it focus + function doTheClick(obj:*):void { + // Give it focus Events.triggerFocusEvent(obj, FocusEvent.FOCUS_IN); // Down, (TextEvent.LINK,) up, click Events.triggerMouseEvent(obj, MouseEvent.MOUSE_DOWN, { @@ -64,7 +75,7 @@ package org.flex_pilot { } //if we have an accordion - if (objType.indexOf('Accordion') != -1){ + if (objType.indexOf('mx.containers::Accordion') != -1){ for(var i:int = 0; i < obj.numChildren; i++) { var atb:Object = obj.getHeaderAt(i) as Object; if (atb.label == params.label) { @@ -79,6 +90,9 @@ package org.flex_pilot { public static function check(params:Object):void { return FPController.click(params); } + + + public static function radio(params:Object):void { return FPController.click(params); } @@ -95,6 +109,14 @@ package org.flex_pilot { var dest:* = FPLocator.lookupDisplayObject(destParams); var destCoords:Point = new Point(0, 0); destCoords = dest.localToGlobal(destCoords); + + if (params.offsetx) { + destCoords.x = destCoords.x + Number(params.offsetx); + } + if (params.offsety) { + destCoords.y = destCoords.y + Number(params.offsety); + } + params.coords = '(' + destCoords.x + ',' + destCoords.y + ')'; dragDropToCoords(params); } @@ -170,6 +192,120 @@ package org.flex_pilot { stepTimer.addEventListener(TimerEvent.TIMER, doStep); stepTimer.start(); } + + public static function dragDrop(params:Object):void { + + var dropLoc:* = FPLocator.lookupDisplayObject(params); + var dragFrom:* = FPLocator.lookupDisplayObject(params.start); + var startParams:*=params.start.params; + var endParams:*=params; + + trace(startParams.stageX , startParams.stageY , endParams.startX , endParams.startY ); + + Events.triggerMouseEvent(dragFrom.stage, MouseEvent.MOUSE_MOVE, { + stageX: startParams.stageX, + stageY: startParams.stageY , + ctrlKey : endParams.ctrlKey , + shiftKey : endParams.shiftKey , + altKey : endParams.altKey + }); + + Events.triggerMouseEvent(dragFrom, MouseEvent.ROLL_OVER); + Events.triggerMouseEvent(dragFrom, MouseEvent.MOUSE_OVER); + Events.triggerFocusEvent(dragFrom, FocusEvent.FOCUS_IN); + + // just a trick . when the data component is fresh and asked to drag , the drag never occurs . + Events.triggerDragEvent(dragFrom , DragEvent.DRAG_START ,startParams); + + dragFrom.validateNow(); + dragFrom.selectedIndices=startParams.selectedIndices; + dragFrom.destroyItemEditor(); + + //ugly but can't help it . . . . component takes some time to set the value for + //selectedIndex and during that time any other activity might result in the required item not being selected + setTimeout(function():void{ + + Events.triggerMouseEvent(dragFrom, MouseEvent.MOUSE_DOWN, { + buttonDown: true , + ctrlKey : endParams.ctrlKey , + shiftKey : endParams.shiftKey , + altKey : endParams.altKey} + ); + + Events.triggerDragEvent(dragFrom , DragEvent.DRAG_START ,startParams); + + var deltaX:int = -startParams.stageX + endParams.stageX; + var deltaY:int = -startParams.stageY + endParams.stageY; + var stepCount:int = 10; // Just pick an arbitrary number of steps + // Number of pixels to move per step + var incrX:Number = deltaX / stepCount; + var incrY:Number = deltaY / stepCount; + // Current pos as the move happens + var currXAbs:Number = startParams.stageX; + var currYAbs:Number = startParams.stageY; + + var pnt:Point=dragFrom.globalToLocal(new Point(currXAbs , currYAbs)); + + var currXLocal:Number = pnt.x; + var currYLocal:Number = pnt.y; + // Step number + var currStep:int = 0; + // Use a delay so we can see the move + var stepTimer:Timer = new Timer(50); + // Step function -- reposition per step + var doStep:Function = function ():void { + trace(currStep); + if (currStep <= stepCount) { + Events.triggerMouseEvent( dragFrom, MouseEvent.MOUSE_MOVE, { + stageX: currXAbs, + stageY: currYAbs, + localX: currXLocal, + localY: currYLocal , + ctrlKey : endParams.ctrlKey , + shiftKey : endParams.shiftKey , + altKey : endParams.altKey + }); + + currXAbs += incrX; + currYAbs += incrY; + currXLocal += incrX; + currYLocal += incrY; + currStep++; + } + + else { + stepTimer.stop(); + Events.triggerMouseEvent( dragFrom, MouseEvent.MOUSE_MOVE, { + stageX: currXAbs, + stageY: currYAbs, + localX: currXLocal, + localY: currYLocal , + ctrlKey : endParams.ctrlKey , + shiftKey : endParams.shiftKey , + altKey : endParams.altKey + }); + + Events.triggerMouseEvent(dropLoc, MouseEvent.ROLL_OVER); + Events.triggerMouseEvent(dropLoc, MouseEvent.MOUSE_OVER); + // Give it focus + Events.triggerFocusEvent(dropLoc, FocusEvent.FOCUS_IN); + Events.triggerMouseEvent(dragFrom, MouseEvent.MOUSE_UP, { + stageX: currXAbs, + stageY: currYAbs, + localX : currXLocal , + localY : currYLocal , + ctrlKey : endParams.ctrlKey , + shiftKey : endParams.shiftKey , + altKey : endParams.altKey + }); + Events.triggerMouseEvent(dragFrom , MouseEvent.CLICK); + } + } + + stepTimer.addEventListener(TimerEvent.TIMER, doStep); + stepTimer.start(); + } , 25); + } // Ensure coords are in the right format and are numbers private static function parseCoords(coordsStr:String):Point { @@ -188,8 +324,9 @@ package org.flex_pilot { } public static function doubleClick(params:Object):void { + //trace("repeat double click"); var obj:* = FPLocator.lookupDisplayObject(params); - + //Figure out what kind of displayObj were dealing with var classInfo:XML = describeType(obj); classInfo = describeType(obj); @@ -270,9 +407,12 @@ package org.flex_pilot { } public static function select(params:Object):void { + + trace("sending"); // Look up the item to write to var obj:* = FPLocator.lookupDisplayObject(params); var sel:* = obj.selectedItem; + var item:*; // Give the item focus Events.triggerFocusEvent(obj, FocusEvent.FOCUS_IN); @@ -304,6 +444,7 @@ package org.flex_pilot { var targetData:String = params.data || params.value; if (sel.data != targetData) { Events.triggerListEvent(obj, ListEvent.CHANGE); + for each (item in obj.dataProvider) { if (item.data == targetData) { obj.selectedItem = item; @@ -311,10 +452,152 @@ package org.flex_pilot { } } break; + case ('indices' in params): + if (obj.selectedIndices != params.indices) { + Events.triggerListEvent(obj, ListEvent.CHANGE); + obj.selectedIndices = params.indices; + } + break; + case ('selectedItem' in params): + var found:Boolean=false; + + for (var i:* in obj.dataProvider) { + found=true; + for (var v:* in params.selectedItem) { + // mx_internal_uid is the additional column added to dataProvider which is visible after some user interaction on the component + if(params.selectedItem[v]!=obj.dataProvider[i][v]&&v.indexOf('mx_internal_uid')==-1){ + found=false; + break; + } + } + + if (found){ + //do the move + obj.validateNow(); + obj.selectedIndex=i; + obj.scrollToIndex(i); + obj.destroyItemEditor(); + Events.triggerListEvent(obj, ListEvent.CHANGE); + break; + } + } + break; default: // Do nothing - } + } } + + public static function sliderChange(params:Object):void{ + var obj:* = FPLocator.lookupDisplayObject(params); + obj.value=params.value; + Events.triggerSliderEvent(obj , 'change'); + } + + public static function dateChange(params:Object):void{ + var obj:* = FPLocator.lookupDisplayObject(params); + trace('params.value' , params.value); + var dat:Date=new Date(params.value); + obj.selectedDate=dat; + Events.triggerCalendarLayoutChangeEvent(obj , 'change'); + } + + public static function dgColumnStretch(params:Object):void{ + var obj:* = FPLocator.lookupDisplayObject(params); + Events.triggerDataGridEvent(obj , DataGridEvent.COLUMN_STRETCH ,params); + } + + public static function dgItemEdit(params:Object):void{ + var obj:* = FPLocator.lookupDisplayObject(params); + Events.triggerDataGridEvent(obj , DataGridEvent.ITEM_EDIT_END ,params); + } + + public static function dgSort(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + Events.triggerDataGridEvent(obj , DataGridEvent.HEADER_RELEASE ,params); + } + + public static function dgHeaderRelease(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + Events.triggerDataGridEvent(obj , DataGridEvent.HEADER_RELEASE ,params); + } + + public static function dgSortAscending(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + params.params.dir=false; + Events.triggerDataGridEvent(obj , FPDataGridEvent.SORT_ASCENDING ,params); + } + + public static function dgSortDescending(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + params.params.dir=true; + Events.triggerDataGridEvent(obj , FPDataGridEvent.SORT_DESCENDING ,params); + } + + FP::complete { + public static function adgItemOpen(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + Events.triggerAdvancedDataGridEvent(obj , AdvancedDataGridEvent.ITEM_OPENING ,params); + } + } + + FP::complete { + public static function adgItemClose(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + Events.triggerAdvancedDataGridEvent(obj , AdvancedDataGridEvent.ITEM_OPENING ,params); + } + } + + FP::complete { + public static function adgColumnStretch(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + Events.triggerAdvancedDataGridEvent(obj , AdvancedDataGridEvent.COLUMN_STRETCH ,params); + } + } + + FP::complete { + public static function adgHeaderShift(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + Events.triggerIndexChangedEvent(obj , IndexChangedEvent.HEADER_SHIFT , params); + } + } + + FP::complete { + public static function adgSort(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + Events.triggerAdvancedDataGridEvent(obj , AdvancedDataGridEvent.HEADER_RELEASE ,params); + } + } + + FP::complete { + public static function adgHeaderRelease(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + Events.triggerAdvancedDataGridEvent(obj , AdvancedDataGridEvent.HEADER_RELEASE ,params); + } + } + + FP::complete { + public static function adgSortAscending(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + params.params.dir=false; + Events.triggerAdvancedDataGridEvent(obj , FPAdvancedDataGridEvent.SORT_ASCENDING , params); + } + } + + FP::complete { + public static function adgSortDescending(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + params.params.dir=true; + Events.triggerAdvancedDataGridEvent(obj , FPAdvancedDataGridEvent.SORT_ASCENDING , params); + } + } + + FP::complete { + public static function adgItemEdit(params:Object):void{ + var obj:*= FPLocator.lookupDisplayObject(params); + Events.triggerAdvancedDataGridEvent(obj , AdvancedDataGridEvent.ITEM_EDIT_END , params); + } + } + public static function getTextValue(params:Object):String { // Look up the item where we want to get the property var obj:* = FPLocator.lookupDisplayObject(params); @@ -329,7 +612,7 @@ package org.flex_pilot { } return res; } - + public static function getPropertyValue(params:Object, opts:Object = null):String { // Look up the item where we want to get the property var obj:* = FPLocator.lookupDisplayObject(params); @@ -349,7 +632,7 @@ package org.flex_pilot { } return String(attrVal); } - + public static function getObjectCoords(params:Object):String { // Look up the item which coords we want to get var obj:* = FPLocator.lookupDisplayObject(params); @@ -358,6 +641,37 @@ package org.flex_pilot { var coords:String = '(' + String(destCoords.x) + ',' + String(destCoords.y) + ')'; return coords; } + + //Dumping the child structure of node and traversing + //for child test building purposes + public static function dump(params:Object):String { + var obj:* = FPLocator.lookupDisplayObject(params); + + var indentString:String = " "; + var output:String = ""; + trace ("-- Starting UI Dump Output --"); + function traceDisplayList(container:DisplayObjectContainer, + indentString:String = ""):void { + var child:DisplayObject; + for (var i:uint=0; i < container.numChildren; i++) { + child = container.getChildAt(i); + var idx:int = container.getChildIndex(child); + try { + trace(indentString, " -- ", "Child Index: "+idx, "Obj: "+ child, "ID: "+ child['id'], "Name: "+ child.name); + output += indentString+" -- Child Index: "+idx+" Obj: "+ child +" ID: "+ child['id']+ " Name: "+ child.name; + } + catch(e:Error) { + trace(indentString, " -- ", "Child Index: "+idx, "Obj: "+ child, "Name: "+ child.name); + output += indentString+" -- Child Index: "+idx+" Obj: "+ child + " Name: "+ child.name; + } + if (container.getChildAt(i) is DisplayObjectContainer){ + traceDisplayList(DisplayObjectContainer(child), indentString + " ") + } + } + } + traceDisplayList(obj); + trace ("-- Finished UI Dump Output --"); + return output; + } } -} - +} \ No newline at end of file diff --git a/src/org/flex_pilot/FPLocator.as b/src/org/flex_pilot/FPLocator.as index bc3a687..6f6ac06 100644 --- a/src/org/flex_pilot/FPLocator.as +++ b/src/org/flex_pilot/FPLocator.as @@ -1,354 +1,420 @@ -/* -Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. - - Licensed 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. -*/ - -package org.flex_pilot { - import org.flex_pilot.FlexPilot; - import org.flex_pilot.FPLogger; - import flash.display.DisplayObject; - import flash.display.DisplayObjectContainer; - import flash.utils.*; - - public class FPLocator { - // Stupid AS3 doesn't iterate over Object keys - // in insertion order - // null for the finder func means use the default - // of findBySimpleAttr - private static var locatorMap:Array = [ - ['name', null], - ['id', null], - ['link', FPLocator.findLink], - ['label', null], - ['htmlText', FPLocator.findHTML], - ['automationName', null] - ]; - private static var locatorMapObj:Object = {}; - private static var locatorMapCreated:Boolean = false; - - // This is the list of attrs we like to use for the - // locators, in order of preference - // FIXME: Need to add some regex fu for pawing through - // text containers for Flash's janky anchor-tag impl - private static var locatorLookupPriority:Array = [ - 'automationName', - 'id', - 'name', - 'label', - 'htmlText' - ]; - - public static function init():void { - for each (var arr:Array in FPLocator.locatorMap) { - FPLocator.locatorMapObj[arr[0]] = arr[1]; - } - FPLocator.locatorMapCreated = true; - } - - public static function lookupDisplayObjectBool( - params:Object):Boolean { - - var res:DisplayObject; - res = FPLocator.lookupDisplayObject(params); - if (res){ - return true; - } - return false; - } - - public static function lookupDisplayObject( - params:Object):DisplayObject { - var res:DisplayObject; - res = lookupDisplayObjectForContext(params, FlexPilot.getContext()); - if (!res && FlexPilot.contextIsApplication()) { - res = lookupDisplayObjectForContext(params, FlexPilot.getStage()); - } - - return res; - } - - public static function lookupDisplayObjectForContext( - params:Object, obj:*):DisplayObject { - - var locators:Array = []; - var queue:Array = []; - - var checkFPLocatorChain:Function = function ( - item:*, pos:int):DisplayObject { - var map:Object = FPLocator.locatorMapObj; - var loc:Object = locators[pos]; - // If nothing specific exists for that attr, use the basic one - var finder:Function = map[loc.attr] || FPLocator.findBySimpleAttr; - var next:int = pos + 1; - if (!!finder(item, loc.attr, loc.val)) { - // Move to the next locator in the chain - // If it's the end of the chain, we have a winner - if (next == locators.length) { - return item; - } - // Otherwise recursively check the next link in - // the locator chain - var count:int = 0; - if (item is DisplayObjectContainer) { - count = item.numChildren; - } - if (count > 0) { - var index:int = 0; - while (index < count) { - var kid:DisplayObject = item.getChildAt(index); - var res:DisplayObject = checkFPLocatorChain(kid, next); - if (res) { - return res; - } - index++; - } - } - } - return null; - }; - - var str:String = normalizeFPLocator(params); - locators = parseFPLocatorChainExpresson(str); - - queue.push(obj); - while (queue.length) { - // Otherwise grab the next item in the queue - var item:* = queue.shift(); - // Append any kids to the end of the queue - if (item is DisplayObjectContainer) { - var count:int = item.numChildren; - var index:int = 0; - while (index < count) { - var kid:DisplayObject = item.getChildAt(index); - queue.push(kid); - index++; - } - } - var res:DisplayObject = checkFPLocatorChain(item, 0); - // If this is a full match, we're done - if (res) { - return res; - } - } - throw new Error("The chain '" + str +"' was not found.") - return null; - } - - private static function parseFPLocatorChainExpresson( - exprStr:String):Array { - var locators:Array = []; - var expr:Array = exprStr.split('/'); - var arr:Array; - for each (var item:String in expr) { - arr = item.split(':'); - locators.push({ - attr: arr[0], - val: arr[1] - }); - } - return locators; - } - - private static function normalizeFPLocator(params:Object):String { - if ('chain' in params) { - return params.chain; - } - else { - var map:Object = FPLocator.locatorMap; - var attr:String; - var val:*; - // FPLocators have an order of precedence -- ComboBox will - // have a name/id, and its sub-options will have label - // Make sure to do name-/id-based lookups first, label last - for each (var item:Array in map) { - if (item[0] in params) { - attr = item[0]; - val = params[attr]; - break; - } - } - return attr + ':' + val; - } - } - - // Default locator for all basic key/val attr matches - private static function findBySimpleAttr( - obj:*, attr:String, val:*):Boolean { - //if we receive a simple attr with an asterix - //we create a regex allowing for wildcard strings - if (val.indexOf("*") != -1) { - if (attr in obj) { - //repalce wildcards with any character match - var valRegExp:String = val.replace(new RegExp("\\*", "g"), "(.*)"); - //force a beginning and end - valRegExp = "^"+valRegExp +"$"; - var wildcard:RegExp = new RegExp(valRegExp); - var result:Object = wildcard.exec(obj[attr]); - return !!(result != null); - } - } - return !!(attr in obj && obj[attr] == val); - } - - // Custom locator for links embedded in htmlText - private static function findLink( - obj:*, attr:String, val:*):Boolean { - var res:Boolean = false; - if ('htmlText' in obj) { - res = !!locateLinkHref(val, obj.htmlText); - } - return res; - } - - // Custom locator for links embedded in htmlText - private static function findHTML( - obj:*, attr:String, val:*):Boolean { - var res:Boolean = false; - if ('htmlText' in obj) { - var text:String = FPLocator.cleanHTML(obj.htmlText); - return val == text; - } - return res; - } - - // Used by the custom locator for links, above - public static function locateLinkHref(linkText:String, - htmlText:String):String { - var pat:RegExp = /()([\s\S]*?)(?:<\/a>)/gi; - var res:Array; - var linkPlain:String = ''; - while (!!(res = pat.exec(htmlText))) { - // Remove HTML tags and linebreaks; and trim - linkPlain = FPLocator.cleanHTML(res[2]); - if (linkPlain == linkText) { - var evPat:RegExp = /href="event:(.*?)"/i; - var arr:Array = evPat.exec(res[1]); - if (!!(arr && arr[1])) { - return arr[1]; - } - else { - return ''; - } - } - } - return ''; - } - - private static function cleanHTML(markup:String):String { - return markup.replace(/<.+?>/g, '').replace( - /\s+/g, ' ').replace(/^ | $/g, ''); - } - - // Generates a chained-locator expression for the clicked-on item - public static function generateLocator(item:*, ...args):String { - var strictLocators:Boolean = FlexPilot.config.strictLocators; - if (args.length) { - strictLocators = args[0]; - } - var expr:String = ''; - var exprArr:Array = []; - var attr:String; - var attrVal:String; - // Verifies the property exists, and that the child can - // be found from the parent (in some cases there is a parent - // which does not have the item in its list of children) - var weHaveAWinner:Function = function (item:*, attr:String):Boolean { - var winner:Boolean = false; - // Get an attribute that actually has a value - if (usableAttr(item, attr)) { - // Make sure that the parent can actually see - // this item in its list of children - var par:* = item.parent; - var count:int = 0; - if (par is DisplayObjectContainer) { - count = par.numChildren; - } - if (count > 0) { - var index:int = 0; - while (index < count) { - var kid:DisplayObject = par.getChildAt(index); - if (kid == item) { - winner = true; - break; - } - index++; - } - } - } - return winner; - }; - var usableAttr:Function = function (item:*, attr:String):Boolean { - // Item has to have an attribute of that name - if (!(attr in item)) { - return false; - } - // Attribute's value cannot be null - if (!item[attr]) { - return false; - } - // If strict locators are on, don't accept an auto-generated - // 'name' attribute ending in a number -- e.g., TextField05 - // These are often unreliable as locators - if (strictLocators && - attr == 'name' && /\d+$/.test(item[attr])) { - return false; - } - return true; - }; - var isValidLookup:Function = function (exprArr:Array):Boolean { - expr = exprArr.join('/'); - // Make sure that the expression actually looks up a - // valid object - var validLookup:DisplayObject = lookupDisplayObject({ - chain: expr - }); - return !!validLookup; - }; - // Attrs to look for, ordered by priority - var locatorPriority:Array = FPLocator.locatorLookupPriority; - do { - // Try looking up a value for each attribute in order - // of preference - for each (attr in locatorPriority) { - // If we find one of the lookuup keys, we may have a winner - if (weHaveAWinner(item, attr)) { - // Prepend onto the locator expression, then check to - // see if the chain still results in a valid lookup - attrVal = attr == 'htmlText' ? - FPLocator.cleanHTML(item[attr]) : item[attr]; - exprArr.unshift(attr + ':' + attrVal); - // If this chain looks up an object correct, keeps going - if (isValidLookup(exprArr)) { - break; - } - // Otherwise throw out this attr/value pair and keep - // trying - else { - exprArr.shift(); - } - } - } - item = item.parent; - } while (item.parent && !(item.parent == FlexPilot.getContext() || - item.parent == FlexPilot.getStage())) - if (exprArr.length) { - expr = exprArr.join('/'); - return expr; - } - else { - return null; - } - } - } -} + +/* +Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. + + Licensed 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. +*/ + +package org.flex_pilot { + import org.flex_pilot.FlexPilot; + import org.flex_pilot.FPLogger; + import flash.display.DisplayObject; + import flash.display.DisplayObjectContainer; + import mx.core.IRawChildrenContainer; + import flash.utils.*; + + public class FPLocator { + // Stupid AS3 doesn't iterate over Object keys + // in insertion order + // null for the finder func means use the default + // of findBySimpleAttr + private static var locatorMap:Array = [ + ['automationName', null], + ['id', null], + ['name', null], + ['link', FPLocator.findLink], + ['label', null], + ['htmlText', FPLocator.findHTML], + ['child', null] + ]; + private static var locatorMapObj:Object = {}; + private static var locatorMapCreated:Boolean = false; + + // This is the list of attrs we like to use for the + // locators, in order of preference + // FIXME: Need to add some regex fu for pawing through + // text containers for Flash's janky anchor-tag impl + private static var locatorLookupPriority:Array = [ + 'automationName', + 'id', + 'name', + 'label', + 'htmlText', + 'child' + ]; + + public static function init():void { + for each (var arr:Array in FPLocator.locatorMap) { + FPLocator.locatorMapObj[arr[0]] = arr[1]; + } + FPLocator.locatorMapCreated = true; + } + + public static function lookupDisplayObjectBool( + params:Object):Boolean { + + var res:DisplayObject; + res = FPLocator.lookupDisplayObject(params); + if (res){ + return true; + } + return false; + } + + public static function lookupDisplayObject( + params:Object):DisplayObject { + var res:DisplayObject; + res = lookupDisplayObjectForContext(params, FlexPilot.getContext()); + if (!res && FlexPilot.contextIsApplication()) { + res = lookupDisplayObjectForContext(params, FlexPilot.getStage()); + } + + return res; + } + + public static function lookupDisplayObjectForContext( + params:Object, obj:*):DisplayObject { + + var locators:Array = []; + var queue:Array = []; + + var checkFPLocatorChain:Function = function ( + item:*, pos:int):DisplayObject { + var map:Object = FPLocator.locatorMapObj; + var loc:Object = locators[pos]; + // If nothing specific exists for that attr, use the basic one + var finder:Function = map[loc.attr] || FPLocator.findBySimpleAttr; + var next:int = pos + 1; + if (!!finder(item, loc.attr, loc.val)) { + // Move to the next locator in the chain + // If it's the end of the chain, we have a winner + if (next == locators.length) { + return item; + } + // Otherwise recursively check the next link in + // the locator chain + var count:int = 0; + if (item is DisplayObjectContainer) { + if (item is IRawChildrenContainer) { + count = item.rawChildren.numChildren; + } + else { + count = item.numChildren; + } + } + if (count > 0) { + var index:int = 0; + while (index < count) { + var kid:DisplayObject; + if (item is IRawChildrenContainer) { + kid = item.rawChildren.getChildAt(index); + } + else { + kid = item.getChildAt(index); + } + var res:DisplayObject = checkFPLocatorChain(kid, next); + if (res) { + return res; + } + index++; + } + } + } + return null; + }; + + var str:String = normalizeFPLocator(params); + locators = parseFPLocatorChainExpresson(str); + queue.push(obj); + while (queue.length) { + // Otherwise grab the next item in the queue + var item:* = queue.shift(); + // Append any kids to the end of the queue + if (item is DisplayObjectContainer) { + var count:int = 0; + if (item is IRawChildrenContainer) { + count = item.rawChildren.numChildren; + } + else { + count = item.numChildren; + } + var index:int = 0; + while (index < count) { + var kid:DisplayObject + if (item is IRawChildrenContainer) { + kid = item.rawChildren.getChildAt(index); + } + else { + kid = item.getChildAt(index); + } + queue.push(kid); + index++; + } + } + var res:DisplayObject = checkFPLocatorChain(item, 0); + // If this is a full match, we're done + if (res) { + return res; + } + } + return null; + } + + private static function parseFPLocatorChainExpresson( + exprStr:String):Array { + var locators:Array = []; + var expr:Array = exprStr.split('/'); + var arr:Array; + for each (var item:String in expr) { + arr = item.split(':'); + locators.push({ + attr: arr[0], + val: arr[1] + }); + } + return locators; + } + + private static function normalizeFPLocator(params:Object):String { + if ('chain' in params) { + return params.chain; + } + else { + var map:Object = FPLocator.locatorMap; + var attr:String; + var val:*; + // FPLocators have an order of precedence -- ComboBox will + // have a name/id, and its sub-options will have label + // Make sure to do name-/id-based lookups first, label last + for each (var item:Array in map) { + if (item[0] in params) { + attr = item[0]; + val = params[attr]; + break; + } + } + return attr + ':' + val; + } + } + + // Default locator for all basic key/val attr matches + private static function findBySimpleAttr( + obj:*, attr:String, val:*):Boolean { + //check to see if a childIndex is specified + var childIndexReg:RegExp = new RegExp("\\[.*\\]", "g"); + var childIndex:String = childIndexReg.exec(val); + //do we have an child index constraint + if (childIndex != null) { + //remove it so it doesn't mess up further matching + val = val.replace(childIndexReg, ""); + childIndex = childIndex.replace("[",""); + childIndex = childIndex.replace("]",""); + var childIndexInt:int = Number(childIndex); + //If this node matches the provided child index + var par:* = obj.parent; + if (par is DisplayObjectContainer) { + var realObjIndex:int; + if (par is IRawChildrenContainer) { + realObjIndex = par.rawChildren.getChildIndex(obj); + } + else { + realObjIndex = par.getChildIndex(obj); + } + //if we were given a childIndex, make sure this passes that req + if (childIndexInt != realObjIndex) { + return false; + } + else if (val == ""){ + return true; + } + } + } + //if we receive a simple attr with an asterix + //we create a regex allowing for wildcard strings + if (val.indexOf("*") != -1) { + if (attr in obj) { + //replace wildcards with any character match + var valRegExp:String = val.replace(new RegExp("\\*", "g"), "(.*)"); + //force a beginning and end + valRegExp = "^"+valRegExp +"$"; + var wildcard:RegExp = new RegExp(valRegExp); + var result:Object = wildcard.exec(obj[attr]); + return !!(result != null); + } + } + return !!(attr in obj && obj[attr] == val); + } + + // Custom locator for links embedded in htmlText + private static function findLink( + obj:*, attr:String, val:*):Boolean { + var res:Boolean = false; + if ('htmlText' in obj) { + res = !!locateLinkHref(val, obj.htmlText); + } + return res; + } + + // Custom locator for links embedded in htmlText + private static function findHTML( + obj:*, attr:String, val:*):Boolean { + var res:Boolean = false; + if ('htmlText' in obj) { + var text:String = FPLocator.cleanHTML(obj.htmlText); + return val == text; + } + return res; + } + + // Used by the custom locator for links, above + public static function locateLinkHref(linkText:String, + htmlText:String):String { + var pat:RegExp = /()([\s\S]*?)(?:<\/a>)/gi; + var res:Array; + var linkPlain:String = ''; + while (!!(res = pat.exec(htmlText))) { + // Remove HTML tags and linebreaks; and trim + linkPlain = FPLocator.cleanHTML(res[2]); + if (linkPlain == linkText) { + var evPat:RegExp = /href="event:(.*?)"/i; + var arr:Array = evPat.exec(res[1]); + if (!!(arr && arr[1])) { + return arr[1]; + } + else { + return ''; + } + } + } + return ''; + } + + private static function cleanHTML(markup:String):String { + return markup.replace(/<.+?>/g, '').replace( + /\s+/g, ' ').replace(/^ | $/g, ''); + } + + // Generates a chained-locator expression for the clicked-on item + public static function generateLocator(item:*, ...args):String { + var strictLocators:Boolean = FlexPilot.config.strictLocators; + if (args.length) { + strictLocators = args[0]; + } + var expr:String = ''; + var exprArr:Array = []; + var attr:String; + var attrVal:String; + // Verifies the property exists, and that the child can + // be found from the parent (in some cases there is a parent + // which does not have the item in its list of children) + var weHaveAWinner:Function = function (item:*, attr:String):Boolean { + var winner:Boolean = false; + // Get an attribute that actually has a value + if (usableAttr(item, attr)) { + // Make sure that the parent can actually see + // this item in its list of children + var par:* = item.parent; + var count:int = 0; + if (par is DisplayObjectContainer) { + if (par is IRawChildrenContainer) { + count = par.rawChildren.numChildren; + } + else { + count = par.numChildren; + } + } + if (count > 0) { + var index:int = 0; + while (index < count) { + var kid:DisplayObject; + if (par is IRawChildrenContainer) { + kid = par.rawChildren.getChildAt(index); + } + else { + kid = par.getChildAt(index); + } + + if (kid == item) { + winner = true; + break; + } + index++; + } + } + } + return winner; + }; + var usableAttr:Function = function (item:*, attr:String):Boolean { + // Item has to have an attribute of that name + if (!(attr in item)) { + return false; + } + // Attribute's value cannot be null + if (!item[attr]) { + return false; + } + // If strict locators are on, don't accept an auto-generated + // 'name' attribute ending in a number -- e.g., TextField05 + // These are often unreliable as locators + if (strictLocators && + attr == 'name' && /\d+$/.test(item[attr])) { + return false; + } + return true; + }; + var isValidLookup:Function = function (exprArr:Array):Boolean { + expr = exprArr.join('/'); + // Make sure that the expression actually looks up a + // valid object + var validLookup:DisplayObject = lookupDisplayObject({ + chain: expr + }); + return !!validLookup; + }; + // Attrs to look for, ordered by priority + var locatorPriority:Array = FPLocator.locatorLookupPriority; + do { + // Try looking up a value for each attribute in order + // of preference + for each (attr in locatorPriority) { + // If we find one of the lookup keys, we may have a winner + if (weHaveAWinner(item, attr)) { + // Prepend onto the locator expression, then check to + // see if the chain still results in a valid lookup + attrVal = attr == 'htmlText' ? + FPLocator.cleanHTML(item[attr]) : item[attr]; + exprArr.unshift(attr + ':' + attrVal); + // If this chain looks up an object correct, keeps going + if (isValidLookup(exprArr)) { + break; + } + // Otherwise throw out this attr/value pair and keep + // trying + else { + exprArr.shift(); + } + } + } + item = item.parent; + } while (item.parent && !(item.parent == FlexPilot.getContext() || + item.parent == FlexPilot.getStage())) + if (exprArr.length) { + expr = exprArr.join('/'); + return expr; + } + else { + return null; + } + } + } +} \ No newline at end of file diff --git a/src/org/flex_pilot/FPLogger.as b/src/org/flex_pilot/FPLogger.as index 72a3276..fd3d2d8 100644 --- a/src/org/flex_pilot/FPLogger.as +++ b/src/org/flex_pilot/FPLogger.as @@ -1,35 +1,35 @@ -/* -Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. - - Licensed 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. -*/ - -package org.flex_pilot { - import flash.external.ExternalInterface; - - public class FPLogger { - public static var modes:Object = { - TRACE: 'trace', - BROWSER: 'browser' - }; - public static var mode:String = modes.BROWSER; - public static function log(msg:*):void { - if (FPLogger.mode == modes.BROWSER) { - ExternalInterface.call("console.log", msg); - } - else { - trace(msg.toString()); - } - } - } -} +/* +Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. + + Licensed 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. +*/ + +package org.flex_pilot { + import flash.external.ExternalInterface; + + public class FPLogger { + public static var modes:Object = { + TRACE: 'trace', + BROWSER: 'browser' + }; + public static var mode:String = modes.TRACE; + public static function log(msg:*):void { + if (FPLogger.mode == modes.BROWSER) { + ExternalInterface.call("console.log", msg); + } + else { + trace(msg.toString()); + } + } + } +} diff --git a/src/org/flex_pilot/FPRecorder.as b/src/org/flex_pilot/FPRecorder.as index b7f53be..793b2e1 100644 --- a/src/org/flex_pilot/FPRecorder.as +++ b/src/org/flex_pilot/FPRecorder.as @@ -15,59 +15,304 @@ Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. */ package org.flex_pilot { - import org.flex_pilot.FlexPilot; - import org.flex_pilot.FPLogger; - import org.flex_pilot.FPLocator; - import org.flex_pilot.FPExplorer; - import flash.utils.*; - import flash.display.Stage; import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; + import flash.display.InteractiveObject; + import flash.display.Stage; + import flash.events.KeyboardEvent; import flash.events.MouseEvent; import flash.events.TextEvent; - import flash.events.KeyboardEvent; - import mx.events.ListEvent; + import flash.external.ExternalInterface; + import flash.text.StaticText; + import flash.utils.*; + + import mx.controls.Button; + import mx.controls.ComboBase; import mx.controls.ComboBox; + import mx.controls.DataGrid; + import mx.controls.DateChooser; + import mx.controls.DateField; import mx.controls.List; - import flash.external.ExternalInterface; + import mx.controls.VSlider; + import mx.controls.dataGridClasses.DataGridBase; + import mx.controls.listClasses.ListBase; + import mx.controls.sliderClasses.Slider; + import mx.core.EventPriority; + import mx.core.UIComponent; + import mx.events.CalendarLayoutChangeEvent; + import mx.events.DataGridEvent; + import mx.events.DragEvent; + import mx.events.IndexChangedEvent; + import mx.events.ListEvent; + import mx.events.SliderEvent; + + import org.flex_pilot.FPExplorer; + import org.flex_pilot.FPLocator; + import org.flex_pilot.FPLogger; + import org.flex_pilot.FlexPilot; + + FP::complete { + import mx.events.AdvancedDataGridEvent; + import mx.controls.listClasses.AdvancedListBase; + import mx.controls.advancedDataGridClasses.AdvancedDataGridBase; + import mx.controls.AdvancedDataGrid; + import mx.controls.AdvancedDataGridBaseEx; + } public class FPRecorder { // Remember the last event type so we know when to // output the stored string from a sequence of keyDown events private static var lastEventType:String; private static var lastEventLocator:String; + + //just to hide the mouse clicks occured while the user is changing the date or value of slider . + private static var noClickTime:Boolean=false; + private static var noClick:*; + // Remember recent target -- used to detect double-click // and to throw away click events on text items that have // already spawned a 'link' TextEvent. // Only remembered for one second private static var recentTarget:Object = { click: null, - change: null + change: null, + sliderChange: null }; + // Timeout id for removing the recentTarget private static var recentTargetTimeout:Object = { click: null, - change: null + change: null, + sliderChange: null, + dateChange: null }; + // String built from a sequenece of keyDown events private static var keyDownString:String = ''; private static var listItems:Array = []; + private static var dateItems:Array=[]; + private static var dgItems:Array=[]; + private static var adgItems:Array=[]; + private static var adgBaseExItems:Array=[]; + private static var uicItems:Array=[]; + private static var sliderItems:Array=[]; private static var running:Boolean = false; + + // just in case u want to record for clicks placed while you are + //performing other user actities Ex. recording of clicks while selecting an item from a list + public static var recordExtraClicks:Boolean=false; + private static var draggerParams:Object; + public static var test:Object; + public static var typesAllowed:Array; + + typesAllowed = [['change' , [Slider,ListBase, ComboBox, DateChooser, DateField]], + ['columnStretch', [DataGrid]], + ['headerRelease', [DataGrid]], + ['itemEditEnd', [DataGrid]], + ['dragDrop', [ListBase]], + ['dragStart', [ListBase]] + ]; + + FP::complete { + typesAllowed=[['change', [Slider, ListBase, ComboBox, AdvancedListBase, DateChooser, DateField]], + ['columnStretch', [DataGrid , AdvancedDataGridBaseEx]], + ['headerRelease', [DataGrid , AdvancedDataGridBaseEx]], + ['itemEditEnd', [DataGrid , AdvancedDataGridBaseEx]], + ['itemOpen', [AdvancedDataGrid]], + ['itemClose', [AdvancedDataGrid]], + ['headerShift', [AdvancedDataGridBaseEx]], + ['dragDrop', [ListBase , AdvancedListBase]], + ['dragStart', [ListBase , AdvancedListBase]] + ]; + } + private static var typesAllowedObj:Object={}; public function FPRecorder():void {} - public static function start():void { // Stop the explorer if it's going FPExplorer.stop(); + + for each(var elem:* in typesAllowed) { + typesAllowedObj[elem[0]]=elem[1]; + } var recurseAttach:Function = function (item:*):void { // Otherwise recursively check the next link in // the locator chain var count:int = 0; - if (item is ComboBox || item is List) { + var i:Number=0; + var arr:Array; + + // With ListBase select event on various other component like DataGrid is also handled . . . . :) + if (item is ComboBox || item is ListBase ) { FPRecorder.listItems.push(item); - item.addEventListener(ListEvent.CHANGE, FPRecorder.handleEvent); + + if (FPRecorder.typesAllowedObj[ListEvent.CHANGE]) { + arr = FPRecorder.typesAllowedObj[ListEvent.CHANGE] as Array; + for (i=0 ; i 0) - tagsToBeKept = tags.split(new RegExp("\\s*,\\s*")); - - var tagsToKeep:Array = new Array(); - for (var i:int = 0; i < tagsToBeKept.length; i++){ - if (tagsToBeKept[i] != null && tagsToBeKept[i] != "") - tagsToKeep.push(tagsToBeKept[i]); - } - - var toBeRemoved:Array = new Array(); - var tagRegExp:RegExp = new RegExp("<([^>\\s]+)(\\s[^>]+)*>", "g"); - - var foundedStrings:Array = html.match(tagRegExp); - for (i = 0; i < foundedStrings.length; i++) { - var tagFlag:Boolean = false; - if (tagsToKeep != null) { - for (var j:int = 0; j < tagsToKeep.length; j++){ - var tmpRegExp:RegExp = new RegExp("<\/?" + tagsToKeep[j] + "( [^<>]*)*>", "i"); - var tmpStr:String = foundedStrings[i] as String; - if (tmpStr.search(tmpRegExp) != -1) - tagFlag = true; - } - } - if (!tagFlag) - toBeRemoved.push(foundedStrings[i]); - } - for (i = 0; i < toBeRemoved.length; i++) { - var tmpRE:RegExp = new RegExp("([\+\*\$\/])","g"); - var tmpRemRE:RegExp = new RegExp((toBeRemoved[i] as String).replace(tmpRE, "\\$1"),"g"); - html = html.replace(tmpRemRE, ""); - } - return html; - } - } -} +/* +Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. + + Licensed 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. +*/ + +package org.flex_pilot { + + public class FPStrip { + public static function strip(html:String, tags:String = ""):String { + var tagsToBeKept:Array = new Array(); + if (tags.length > 0) + tagsToBeKept = tags.split(new RegExp("\\s*,\\s*")); + + var tagsToKeep:Array = new Array(); + for (var i:int = 0; i < tagsToBeKept.length; i++){ + if (tagsToBeKept[i] != null && tagsToBeKept[i] != "") + tagsToKeep.push(tagsToBeKept[i]); + } + + var toBeRemoved:Array = new Array(); + var tagRegExp:RegExp = new RegExp("<([^>\\s]+)(\\s[^>]+)*>", "g"); + + var foundedStrings:Array = html.match(tagRegExp); + for (i = 0; i < foundedStrings.length; i++) { + var tagFlag:Boolean = false; + if (tagsToKeep != null) { + for (var j:int = 0; j < tagsToKeep.length; j++){ + var tmpRegExp:RegExp = new RegExp("<\/?" + tagsToKeep[j] + "( [^<>]*)*>", "i"); + var tmpStr:String = foundedStrings[i] as String; + if (tmpStr.search(tmpRegExp) != -1) + tagFlag = true; + } + } + if (!tagFlag) + toBeRemoved.push(foundedStrings[i]); + } + for (i = 0; i < toBeRemoved.length; i++) { + var tmpRE:RegExp = new RegExp("([\+\*\$\/])","g"); + var tmpRemRE:RegExp = new RegExp((toBeRemoved[i] as String).replace(tmpRE, "\\$1"),"g"); + html = html.replace(tmpRemRE, ""); + } + return html; + } + } +} diff --git a/src/org/flex_pilot/FPWait.as b/src/org/flex_pilot/FPWait.as index 2c89464..42724a2 100644 --- a/src/org/flex_pilot/FPWait.as +++ b/src/org/flex_pilot/FPWait.as @@ -1,122 +1,122 @@ -/* -Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. - - Licensed 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. -*/ - -package org.flex_pilot { - import org.flex_pilot.FlexPilot; - import org.flex_pilot.FPLogger; - import org.flex_pilot.FPLocator; - import org.flex_pilot.astest.ASTest; - import flash.utils.*; - - public class FPWait { - // Simple wait function -- puts ASTest into waiting - // mode, calls a function on setTimeout to take it - // back out of waiting mode - public static function sleep(params:Object):void { - ASTest.waiting = true; - setTimeout(function ():void { - ASTest.waiting = false; - }, params.milliseconds); - } - - // Generic wait function which waits for a true result - // from a test function (params.test) - // All other waits should simply define a test function - // and hand off to this - // Default timeout (FlexPilot.config.timeout) is 20 seconds -- - // can be overridden with params.timeout - public static function forCondition(params:Object, - callback:Function = null):void { - var timeout:int = FlexPilot.config.timeout; - if (params.timeout) { - if (!isNaN(parseInt(params.timeout, 10))) { - timeout = params.timeout; - } - } - var testFunc:Function = params.test; - var timeoutCounter:int = 0; - var loopInterval:int = 100; - - ASTest.waiting = true; - - // Recursively call the test function, and set - // ASTest.waiting back to false if the code ever suceeds - // Throw an error if this loop times out without - // the test function ever succeeding - var conditionTest:Function = function ():void { - - // If test function never returns a true result, time out. - // Can't throw an actual error here, because after the first - // setTimeout, this recursive call-loop executes outside the - // scope of the original try/catch in the ASTest.runNextTest - // loop. So rather than throwing here, we hang the error on - // ASTest.previousError, so when runNextTest resumes, it will - // find it and report it before running the next test action - if (timeoutCounter > timeout) { - ASTest.previousError = new Error( - 'Wait timed out after ' + timeout + ' milliseconds.'); - ASTest.waiting = false; - return; - } - - // Not timed out, so increment the counter and go on - timeoutCounter += loopInterval; - - // Exec the test function, and cast it to a Bool - var result:*; - try { - result = testFunc(); - } - // If it throws an error, just try again -- if it never - // succeeds, the timeout code will handle it - catch (e:Error) { - return; - } - result = !!result; - - // Success -- switch off waiting state so ASTest.runNextTest - // will resume - if (result) { - if (callback is Function) { - try { - callback(); - } - catch (e:Error) { - ASTest.previousError = e; - } - } - ASTest.waiting = false; - return; - } - // Otherwise keep trying until it times out - else { - setTimeout(conditionTest, loopInterval); - } - }; - conditionTest(); // Start the recursive calling process - } - - public static function forDisplayObject(params:Object, - callback:Function = null):void { - var func:Function = function ():Boolean { - var obj:* = FPLocator.lookupDisplayObject(params); - return !!obj - } - params.test = func; - return FPWait.forCondition(params, callback); - } - } -} +/* +Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. + + Licensed 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. +*/ + +package org.flex_pilot { + import org.flex_pilot.FlexPilot; + import org.flex_pilot.FPLogger; + import org.flex_pilot.FPLocator; + import org.flex_pilot.astest.ASTest; + import flash.utils.*; + + public class FPWait { + // Simple wait function -- puts ASTest into waiting + // mode, calls a function on setTimeout to take it + // back out of waiting mode + public static function sleep(params:Object):void { + ASTest.waiting = true; + setTimeout(function ():void { + ASTest.waiting = false; + }, params.milliseconds); + } + + // Generic wait function which waits for a true result + // from a test function (params.test) + // All other waits should simply define a test function + // and hand off to this + // Default timeout (FlexPilot.config.timeout) is 20 seconds -- + // can be overridden with params.timeout + public static function forCondition(params:Object, + callback:Function = null):void { + var timeout:int = FlexPilot.config.timeout; + if (params.timeout) { + if (!isNaN(parseInt(params.timeout, 10))) { + timeout = params.timeout; + } + } + var testFunc:Function = params.test; + var timeoutCounter:int = 0; + var loopInterval:int = 100; + + ASTest.waiting = true; + + // Recursively call the test function, and set + // ASTest.waiting back to false if the code ever suceeds + // Throw an error if this loop times out without + // the test function ever succeeding + var conditionTest:Function = function ():void { + + // If test function never returns a true result, time out. + // Can't throw an actual error here, because after the first + // setTimeout, this recursive call-loop executes outside the + // scope of the original try/catch in the ASTest.runNextTest + // loop. So rather than throwing here, we hang the error on + // ASTest.previousError, so when runNextTest resumes, it will + // find it and report it before running the next test action + if (timeoutCounter > timeout) { + ASTest.previousError = new Error( + 'Wait timed out after ' + timeout + ' milliseconds.'); + ASTest.waiting = false; + return; + } + + // Not timed out, so increment the counter and go on + timeoutCounter += loopInterval; + + // Exec the test function, and cast it to a Bool + var result:*; + try { + result = testFunc(); + } + // If it throws an error, just try again -- if it never + // succeeds, the timeout code will handle it + catch (e:Error) { + return; + } + result = !!result; + + // Success -- switch off waiting state so ASTest.runNextTest + // will resume + if (result) { + if (callback is Function) { + try { + callback(); + } + catch (e:Error) { + ASTest.previousError = e; + } + } + ASTest.waiting = false; + return; + } + // Otherwise keep trying until it times out + else { + setTimeout(conditionTest, loopInterval); + } + }; + conditionTest(); // Start the recursive calling process + } + + public static function forDisplayObject(params:Object, + callback:Function = null):void { + var func:Function = function ():Boolean { + var obj:* = FPLocator.lookupDisplayObject(params); + return !!obj + } + params.test = func; + return FPWait.forCondition(params, callback); + } + } +} diff --git a/src/org/flex_pilot/FlexPilot.as b/src/org/flex_pilot/FlexPilot.as index 1d1f4a6..a58fc0d 100644 --- a/src/org/flex_pilot/FlexPilot.as +++ b/src/org/flex_pilot/FlexPilot.as @@ -1,207 +1,210 @@ -/* -Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. - - Licensed 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. -*/ - -package org.flex_pilot { - import org.flex_pilot.astest.ASTest; - import org.flex_pilot.FPLocator; - import org.flex_pilot.FPController; - import org.flex_pilot.FPAssert; - import flash.utils.*; - import mx.core.Application; - import flash.system.Security; - import flash.display.Sprite; - import flash.display.Stage; - import flash.display.DisplayObject; - import flash.external.ExternalInterface; - import com.adobe.serialization.json.JSON; - - public class FlexPilot extends Sprite { - public static var config:Object = { - context: null, // Ref to the Stage or Application - timeout: 20000, // Default timeout for waits - domains: [], - strictLocators: false - }; - public static var controllerMethods:Array = []; - public static var assertMethods:Array = []; - public static var packages:Object = { - controller: { - // Ref to the namespace, since you can't - // do it via string lookup - packageRef: org.flex_pilot.FPController, - // Gets filled with the list of public methods -- - // used to generate the wrapped methods exposed - // via ExternalInterface - methodNames: [] - }, - assert: { - packageRef: org.flex_pilot.FPAssert, - methodNames: [] - } - }; - - // Initializes the FlexPilot Flash code - // 1. Saves a reference to the stage in config.context - // this is the equivalent of the window obj in - // FlexPilot's JS impl. See FPLocator to see how - // it's used - // 2. Does some introspection/metaprogramming to - // expose all the public methods in FPController - // and FPAsserts through the ExternalInterface - // as wrapped functions that return either the - // Boolean true, or the Error object if an error - // happens (as in the case of all failed tests) - // 3. Exposes the start/stop method of FPExplorer - // to turn on and off the explorer - public static function init(params:Object):void { - var methodName:String; - var item:*; - var descr:XML; - // A reference to the Stage - // ---------------- - if (!(params.context is Stage || params.context is Application)) { - throw new Error('FlexPilot.config.context must be a reference to the Application or Stage.'); - } - config.context = params.context; - - // Allow script access to talk to the FlexPilot API - // via ExternalInterface from the following domains - if ('domains' in params) { - var domainsArr:Array = params.domain is Array ? - params.domains : [params.domains]; - config.domains = domainsArr; - for each (var d:String in config.domains) { - FlexPilot.addDomain(d); - } - } - - // Set up the locator map - // ======== - FPLocator.init(); - // Create dynamic asserts - // ======== - FPAssert.init(); - - // Returns a wrapped version of the method that returns - // the Error obj to JS-land instead of actually throwing - var genExtFunc:Function = function (func:Function):Function { - return function (...args):* { - try { - for (var arg:* in args){ - // Terrible hack working around half baked - // ExternalInterface support provided by - // Safari on Windows - // takes json strings and turns them into objects - if (args[arg] is String){ - var o : Object = JSON.decode(args[arg]); - args[arg] = o; - } - } - return func.apply(null, args); - } - catch (e:Error) { - return e; - } - } - } - - // Expose controller and non-dynamic assert methods - // ---------------- - for (var key:String in packages) { - // Introspect all the public packages - // to expose via ExternalInterface - descr = flash.utils.describeType( - packages[key].packageRef); - for each (item in descr..method) { - packages[key].methodNames.push(item.@name.toXMLString()); - } - // Expose public packages via ExternalInterface - // 'dragDropOnCoords' becomes 'fp_dragDropOnCoords' - // The exposed method is wrapped in a try/catch - // that returns the Error obj to JS instead of throwing - for each (methodName in packages[key].methodNames) { - ExternalInterface.addCallback('fp_' + methodName, - genExtFunc(packages[key].packageRef[methodName])); - } - } - - // Expose dynamic asserts - // ---------------- - // These *will not* - // show up via introspection with describeType, but - // they *are there* -- add them manually by iterating - // through the same list that used to build them - var asserts:* = FPAssert; - for (methodName in asserts.assertTemplates) { - ExternalInterface.addCallback('fp_' + methodName, - genExtFunc(asserts[methodName])); - - } - - // Other misc ExternalInterface methods - // ---------------- - var miscMethods:Object = { - explorerStart: FPExplorer.start, - explorerStop: FPExplorer.stop, - recorderStart: FPRecorder.start, - recorderStop: FPRecorder.stop, - runASTests: ASTest.run, - lookupFlash: FPLocator.lookupDisplayObjectBool - } - for (methodName in miscMethods) { - ExternalInterface.addCallback('fp_' + methodName, - genExtFunc(miscMethods[methodName])); - } - - // Wrap controller methods for AS tests to do auto-wait - // ======== - ASTest.init(); - } - - public static function addDomain(domain:String):void { - flash.system.Security.allowDomain(domain); - } - - public static function contextIsStage():Boolean { - return (config.context is Stage); - } - - public static function contextIsApplication():Boolean { - return (config.context is Application); - } - - public static function getContext():* { - return config.context; - } - - public static function getStage():Stage { - var context:* = config.context; - var stage:Stage; - if (contextIsApplication()) { - stage = context.stage; - } - else if (contextIsStage()) { - stage = context; - } - else { - throw new Error('FlexPilot.config.context must be a reference to an Application or Stage.' + - ' Perhaps FlexPilot.init has not run yet.'); - } - return stage; - } - - } -} +/* +Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. + + Licensed 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. +*/ + +package org.flex_pilot { + import org.flex_pilot.astest.ASTest; + import org.flex_pilot.FPLocator; + import org.flex_pilot.FPController; + import org.flex_pilot.FPAssert; + import flash.utils.*; + import mx.core.Application; + import flash.system.Security; + import flash.display.Sprite; + import flash.display.Stage; + import flash.display.DisplayObject; + import flash.external.ExternalInterface; + import com.adobe.serialization.json.JSON; + + public class FlexPilot extends Sprite { + public static var config:Object = { + context: null, // Ref to the Stage or Application + timeout: 20000, // Default timeout for waits + domains: [], + strictLocators: false + }; + public static var controllerMethods:Array = []; + public static var assertMethods:Array = []; + public static var packages:Object = { + controller: { + // Ref to the namespace, since you can't + // do it via string lookup + packageRef: org.flex_pilot.FPController, + // Gets filled with the list of public methods -- + // used to generate the wrapped methods exposed + // via ExternalInterface + methodNames: [] + }, + assert: { + packageRef: org.flex_pilot.FPAssert, + methodNames: [] + } + }; + + // Initializes the FlexPilot Flash code + // 1. Saves a reference to the stage in config.context + // this is the equivalent of the window obj in + // FlexPilot's JS impl. See FPLocator to see how + // it's used + // 2. Does some introspection/metaprogramming to + // expose all the public methods in FPController + // and FPAsserts through the ExternalInterface + // as wrapped functions that return either the + // Boolean true, or the Error object if an error + // happens (as in the case of all failed tests) + // 3. Exposes the start/stop method of FPExplorer + // to turn on and off the explorer + public static function init(params:Object):void { + var methodName:String; + var item:*; + var descr:XML; + // A reference to the Stage + // ---------------- + if (!(params.context is Stage || params.context is Application)) { + throw new Error('FlexPilot.config.context must be a reference to the Application or Stage.'); + } + config.context = params.context; + + // Allow script access to talk to the FlexPilot API + // via ExternalInterface from the following domains + if ('domains' in params) { + var domainsArr:Array = params.domain is Array ? + params.domains : [params.domains]; + config.domains = domainsArr; + for each (var d:String in config.domains) { + FlexPilot.addDomain(d); + } + } + + // Set up the locator map + // ======== + FPLocator.init(); + // Create dynamic asserts + // ======== + FPAssert.init(); + + // Returns a wrapped version of the method that returns + // the Error obj to JS-land instead of actually throwing + var genExtFunc:Function = function (func:Function):Function { + return function (...args):* { + try { + for (var arg:* in args) { + // Terrible hack working around half baked + // ExternalInterface support provided by + // Safari on Windows + // takes json strings and turns them into objects + if (args[arg] is String) { + var o : Object = JSON.decode(args[arg]); + args[arg] = o; + } + } + return func.apply(null, args); + } + catch (e:Error) { + if (e.errorID == 1009){ + e.message = "There was a problem with your parameters, " + JSON.encode(args); + } + return e; + } + } + } + + // Expose controller and non-dynamic assert methods + // ---------------- + for (var key:String in packages) { + // Introspect all the public packages + // to expose via ExternalInterface + descr = flash.utils.describeType( + packages[key].packageRef); + for each (item in descr..method) { + packages[key].methodNames.push(item.@name.toXMLString()); + } + // Expose public packages via ExternalInterface + // 'dragDropOnCoords' becomes 'fp_dragDropOnCoords' + // The exposed method is wrapped in a try/catch + // that returns the Error obj to JS instead of throwing + for each (methodName in packages[key].methodNames) { + ExternalInterface.addCallback('fp_' + methodName, + genExtFunc(packages[key].packageRef[methodName])); + } + } + + // Expose dynamic asserts + // ---------------- + // These *will not* + // show up via introspection with describeType, but + // they *are there* -- add them manually by iterating + // through the same list that used to build them + var asserts:* = FPAssert; + for (methodName in asserts.assertTemplates) { + ExternalInterface.addCallback('fp_' + methodName, + genExtFunc(asserts[methodName])); + + } + + // Other misc ExternalInterface methods + // ---------------- + var miscMethods:Object = { + explorerStart: FPExplorer.start, + explorerStop: FPExplorer.stop, + recorderStart: FPRecorder.start, + recorderStop: FPRecorder.stop, + runASTests: ASTest.run, + lookupFlash: FPLocator.lookupDisplayObjectBool + } + for (methodName in miscMethods) { + ExternalInterface.addCallback('fp_' + methodName, + genExtFunc(miscMethods[methodName])); + } + + // Wrap controller methods for AS tests to do auto-wait + // ======== + ASTest.init(); + } + + public static function addDomain(domain:String):void { + flash.system.Security.allowDomain(domain); + } + + public static function contextIsStage():Boolean { + return (config.context is Stage); + } + + public static function contextIsApplication():Boolean { + return (config.context is Application); + } + + public static function getContext():* { + return config.context; + } + + public static function getStage():Stage { + var context:* = config.context; + var stage:Stage; + if (contextIsApplication()) { + stage = context.stage; + } + else if (contextIsStage()) { + stage = context; + } + else { + throw new Error('FlexPilot.config.context must be a reference to an Application or Stage.' + + ' Perhaps FlexPilot.init has not run yet.'); + } + return stage; + } + + } +} \ No newline at end of file diff --git a/src/org/flex_pilot/astest/ASTest.as b/src/org/flex_pilot/astest/ASTest.as index ab42cff..b9928f8 100644 --- a/src/org/flex_pilot/astest/ASTest.as +++ b/src/org/flex_pilot/astest/ASTest.as @@ -1,300 +1,300 @@ /* Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. - Licensed 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 +Licensed 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 +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. +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. */ package org.flex_pilot.astest { - import org.flex_pilot.FlexPilot; - import org.flex_pilot.FPLocator; - import org.flex_pilot.FPController; - import org.flex_pilot.FPWait; - import org.flex_pilot.FPLogger; - import flash.utils.*; - import flash.external.ExternalInterface; - - public class ASTest { - // How long to wait between each test action - private static const TEST_INTERVAL:int = 10; - // List of all the test classes for this test run - public static var testClassList:Array = []; - // The complete list of all methods for each class - // in this test run - private static var testListComplete:Array = []; - // Copy of the list of tests -- items are popped - // of to run the tests - private static var testList:Array = []; - // The last test action -- used to do reporting on - // success/failure of each test. Waits happen - // async in a setTimeout loop, so reporting happens - // for the *previous* test at the beginning of each - // runNextTest call, before grabbing and running the - // next test - private static var previousTest:Object = null; - // Error for the previous test if it was unsuccessful - // Used in the reporting as described above - public static var previousError:Object = false; - // Tests are running or not - public static var inProgress:Boolean = false; - // In waiting mode, the runNextTest loop just idles - public static var waiting:Boolean = false; - - public static var wrappedControllerMethods:Object = {}; - - public static function init():void { - var methodNames:Array = FlexPilot.packages.controller.methodNames; - // Returns a controller action wrapped in a wait for the - // desired DisplayObject -- action is passed as a callback - // to FPWait.forDisplayObject - var wrapAutoWait:Function = function (key:String):Function { - return function (params:Object):void { - FPWait.forDisplayObject(params, function ():void { - FPController[key](params); - }); - } - } - // For each controller-action method in FPController, - // create an auto-wait-wrapped version to call from the - // AS tests. 'controller' in the TestCase base class - // points to wrappedControllerMethods - for each (var key:String in methodNames) { - wrappedControllerMethods[key] = wrapAutoWait(key); - } - } - - public static function run(files:* = null):void { - //['/flash/TestFoo.swf', '/flash/TestBar.swf'] - // If we're passed some files, load 'em up first - // the loader will call back to this again when - // it's done, with no args - if (files) { - // **** Ugly hack **** - // ------------- - if (!(files is Array)) { - // The files param passed in from XPCOM trusted JS - // loses its Array-ness -- fails the 'is Array' test, - // and has no 'length' property. It's just a generic - // Object with integers for keys - // In that case, reconstitute the Array by manually - // stepping through it until we run out of items - var filesTemp:Array = []; - var incr:int = 0; - var item:*; - var keepGoing:Boolean = true; - while (keepGoing) { - item = files[incr]; - if (item) { - filesTemp.push(item); - } - else { - keepGoing = false; - } - incr++; - } - files = filesTemp; - } - // ------------- - ASTest.loadTestFiles(files); - return; - } - ASTest.getCompleteListOfTests(); - ASTest.start(); - } - - public static function loadTestFiles(files:Array):void { - // Clear out the list of tests before loading - ASTest.testClassList = []; - ASTest.testList = []; - // Load the shit - ASTestLoader.load(files); - } - - public static function start():void { - // Make a copy of the tests to work on - ASTest.testList = ASTest.testListComplete.slice(); - ASTest.inProgress = true; - // Run recursively in a setTimeout loop so - // we can implement sleeps and waits - ASTest.runNextTest(); - } - - public static function runNextTest():void { - var test:Object = null; - var res:*; // Result from ExternalInterface calls - var data:Object; - // If we're idling in a wait, just move along ... - // Nothing to see here - if (ASTest.waiting) { - // Let's try again in a second or so - setTimeout(function ():void { - ASTest.runNextTest.call(ASTest); - }, 1000); - return; - } - // Do reporting for the previous test -- we do this here - // because waits happen async in a setTimeout loop, - // and we only know when it has finished by when the next - // test actually starts - if (ASTest.previousTest) { - test = ASTest.previousTest; - data = { - test: { - className: test.className, - methodName: test.methodName - }, - error: null - }; - // Error - if (ASTest.previousError) { - data.error = ASTest.previousError; - ASTest.previousError = null; - } - - // Report via ExternalInterface, or log results - res = ExternalInterface.call('fp_asTestResult', data); - if (!res) { - if (data.error) { - FPLogger.log('FAILURE: ' + data.error.message); - } - else { - FPLogger.log('SUCCESS'); - } - } - ASTest.previousTest = null; - } - - // If we're out of tests, we're all done - // TODO: Add some kind of final report - if (ASTest.testList.length == 0) { - ASTest.inProgress = false; - } - // If we still have tests to run, grab the next one - // and run that bitch - else { - test = ASTest.testList.shift(); - // Save a ref to this test to use for reporting - // at the beginning of the next call - ASTest.previousTest = test; - - data = { - test: { - className: test.className, - methodName: test.methodName - } - }; - res = ExternalInterface.call('fp_asTestStart', data); - if (!res) { - FPLogger.log('Running ' + test.className + '.' + test.methodName + ' ...'); - } - - // Run the test - // ----------- - try { - if (!(test.methodName in test.instance)) { - throw new Error('"' + test.methodName + - '" is not a valid method in' + test.instance.toString()); - } - test.instance[test.methodName].call(test.instance); - } - catch (e:Error) { - // Save a ref to the error to use for reporting - // at the beginning of the next call - ASTest.previousError = e; - } - - // Recurse until done -- note this is not actually a - // tail call because the setTimeout invokes the function - // in the global execution context - setTimeout(function ():void { - ASTest.runNextTest.call(ASTest); - }, ASTest.TEST_INTERVAL); - } - } - - public static function getCompleteListOfTests():void { - var createTestItem:Function = function (item:Object, - methodName:String):Object { - return { - methodName: methodName, - instance: item.instance, - className: item.className, - classDescription: item.classDescription - }; - } - var testList:Array = []; - // No args -- this is being re-invoked from ASTestLoader - // now that we have our tests loaded - for each (var item:Object in ASTest.testClassList) { - var currTestList:Array = []; - var descr:XML; - var hasSetup:Boolean = false; - var hasTeardown:Boolean = false; - descr = flash.utils.describeType( - item.classDescription); - var meth:*; - var methods:Object = {}; - for each (meth in descr..method) { - var methodName:String = meth.@name.toXMLString(); - if (/^test/.test(methodName)) { - methods[methodName] = item; - } - // If there's a setup or teardown somewhere in there - // flag them so we can prepend/append after adding all - // the tests - if (methodName == 'setup') { - hasSetup = true; - } - if (methodName == 'teardown') { - hasTeardown = true; - } - } - - // Normal test methods - // ----- - // If there's an 'order' array defined, run any tests - // it contains in the defined order - var key:String; - if ('order' in item.instance) { - for each (key in item.instance.order) { - // If the item specified in the 'order' list is an actual - // method, add it to the list -- if it doesn't actually exist - // (e.g., if the method has been commented out), just ignore it - if (key in methods) { - currTestList.push(createTestItem(methods[key], key)); - delete methods[key]; - } - } - } - // Run any other methods in whatever order - for (key in methods) { - currTestList.push(createTestItem(methods[key], key)); - } - - // Setup/teardown - // ----- - // Prepend list with setup if one exists - if (hasSetup) { - currTestList.unshift(createTestItem(item, 'setup')); - } - // Append list with teardown if one exists - if (hasTeardown) { - currTestList.push(createTestItem(item, 'teardown')); - } - testList = testList.concat.apply(testList, currTestList); - } - ASTest.testListComplete = testList; - } - } + import flash.external.ExternalInterface; + import flash.utils.*; + + import org.flex_pilot.FPController; + import org.flex_pilot.FPLocator; + import org.flex_pilot.FPLogger; + import org.flex_pilot.FPWait; + import org.flex_pilot.FlexPilot; + + public class ASTest { + // How long to wait between each test action + private static const TEST_INTERVAL:int = 10; + // List of all the test classes for this test run + public static var testClassList:Array = []; + // The complete list of all methods for each class + // in this test run + public static var testListComplete:Array = []; + // Copy of the list of tests -- items are popped + // of to run the tests + private static var testList:Array = []; + // The last test action -- used to do reporting on + // success/failure of each test. Waits happen + // async in a setTimeout loop, so reporting happens + // for the *previous* test at the beginning of each + // runNextTest call, before grabbing and running the + // next test + private static var previousTest:Object = null; + // Error for the previous test if it was unsuccessful + // Used in the reporting as described above + public static var previousError:Object = false; + // Tests are running or not + public static var inProgress:Boolean = false; + // In waiting mode, the runNextTest loop just idles + public static var waiting:Boolean = false; + + public static var wrappedControllerMethods:Object = {}; + + public static function init():void { + var methodNames:Array = FlexPilot.packages.controller.methodNames; + // Returns a controller action wrapped in a wait for the + // desired DisplayObject -- action is passed as a callback + // to FPWait.forDisplayObject + var wrapAutoWait:Function = function (key:String):Function { + return function (params:Object):void { + FPWait.forDisplayObject(params, function ():void { + FPController[key](params); + }); + } + } + // For each controller-action method in FPController, + // create an auto-wait-wrapped version to call from the + // AS tests. 'controller' in the TestCase base class + // points to wrappedControllerMethods + for each (var key:String in methodNames) { + wrappedControllerMethods[key] = wrapAutoWait(key); + } + } + + public static function run(files:* = null):void { + //['/flash/TestFoo.swf', '/flash/TestBar.swf'] + // If we're passed some files, load 'em up first + // the loader will call back to this again when + // it's done, with no args + if (files) { + // **** Ugly hack **** + // ------------- + if (!(files is Array)) { + // The files param passed in from XPCOM trusted JS + // loses its Array-ness -- fails the 'is Array' test, + // and has no 'length' property. It's just a generic + // Object with integers for keys + // In that case, reconstitute the Array by manually + // stepping through it until we run out of items + var filesTemp:Array = []; + var incr:int = 0; + var item:*; + var keepGoing:Boolean = true; + while (keepGoing) { + item = files[incr]; + if (item) { + filesTemp.push(item); + } + else { + keepGoing = false; + } + incr++; + } + files = filesTemp; + } + // ------------- + ASTest.loadTestFiles(files); + return; + } + ASTest.getCompleteListOfTests(); + ASTest.start(); + } + + public static function loadTestFiles(files:Array):void { + // Clear out the list of tests before loading + ASTest.testClassList = []; + ASTest.testList = []; + // Load the shit + ASTestLoader.load(files); + } + + public static function start():void { + // Make a copy of the tests to work on + ASTest.testList = ASTest.testListComplete.slice(); + ASTest.inProgress = true; + // Run recursively in a setTimeout loop so + // we can implement sleeps and waits + ASTest.runNextTest(); + } + + public static function runNextTest():void { + var test:Object = null; + var res:*; // Result from ExternalInterface calls + var data:Object; + // If we're idling in a wait, just move along ... + // Nothing to see here + if (ASTest.waiting) { + // Let's try again in a second or so + setTimeout(function ():void { + ASTest.runNextTest.call(ASTest); + }, 1000); + return; + } + // Do reporting for the previous test -- we do this here + // because waits happen async in a setTimeout loop, + // and we only know when it has finished by when the next + // test actually starts + if (ASTest.previousTest) { + test = ASTest.previousTest; + data = { + test: { + className: test.className, + methodName: test.methodName + }, + error: null + }; + // Error + if (ASTest.previousError) { + data.error = ASTest.previousError; + ASTest.previousError = null; + } + + // Report via ExternalInterface, or log results + res = ExternalInterface.call('fp_asTestResult', data); + if (!res) { + if (data.error) { + FPLogger.log('FAILURE: ' + data.error.message); + } + else { + FPLogger.log('SUCCESS'); + } + } + ASTest.previousTest = null; + } + + // If we're out of tests, we're all done + // TODO: Add some kind of final report + if (ASTest.testList.length == 0) { + ASTest.inProgress = false; + } + // If we still have tests to run, grab the next one + // and run that bitch + else { + test = ASTest.testList.shift(); + // Save a ref to this test to use for reporting + // at the beginning of the next call + ASTest.previousTest = test; + + data = { + test: { + className: test.className, + methodName: test.methodName + } + }; + res = ExternalInterface.call('fp_asTestStart', data); + if (!res) { + FPLogger.log('Running ' + test.className + '.' + test.methodName + ' ...'); + } + + // Run the test + // ----------- + try { + if (!(test.methodName in test.instance)) { + throw new Error('"' + test.methodName + + '" is not a valid method in' + test.instance.toString()); + } + test.instance[test.methodName].call(test.instance); + } + catch (e:Error) { + // Save a ref to the error to use for reporting + // at the beginning of the next call + ASTest.previousError = e; + } + + // Recurse until done -- note this is not actually a + // tail call because the setTimeout invokes the function + // in the global execution context + setTimeout(function ():void { + ASTest.runNextTest.call(ASTest); + }, ASTest.TEST_INTERVAL); + } + } + + public static function getCompleteListOfTests():void { + var createTestItem:Function = function (item:Object, + methodName:String):Object { + return { + methodName: methodName, + instance: item, + className: getQualifiedClassName(item), + classDescription: describeType(item) + }; + } + var testList:Array = []; + // No args -- this is being re-invoked from ASTestLoader + // now that we have our tests loaded + for each (var item:Object in ASTest.testClassList) { + var currTestList:Array = []; + var descr:XML; + var hasSetup:Boolean = false; + var hasTeardown:Boolean = false; + descr = flash.utils.describeType(item); + var meth:*; + var methods:Object = {}; + for each (meth in descr..method) { + var methodName:String = meth.@name.toXMLString(); + if (/^test/.test(methodName)) { + methods[methodName] = item; + } + // If there's a setup or teardown somewhere in there + // flag them so we can prepend/append after adding all + // the tests + if (methodName == 'setup') { + hasSetup = true; + } + if (methodName == 'teardown') { + hasTeardown = true; + } + } + + // Normal test methods + // ----- + // If there's an 'order' array defined, run any tests + // it contains in the defined order + var key:String; + if ('order' in item) { + for each (key in item.order) { + // If the item specified in the 'order' list is an actual + // method, add it to the list -- if it doesn't actually exist + // (e.g., if the method has been commented out), just ignore it + if (key in methods) { + currTestList.push(createTestItem(methods[key], key)); + delete methods[key]; + } + } + } + // Run any other methods in whatever order + for (key in methods) { + currTestList.push(createTestItem(methods[key], key)); + } + + // Setup/teardown + // ----- + // Prepend list with setup if one exists + if (hasSetup) { + currTestList.unshift(createTestItem(item, 'setup')); + } + // Append list with teardown if one exists + if (hasTeardown) { + currTestList.push(createTestItem(item, 'teardown')); + } + testList = testList.concat.apply(testList, currTestList); + } + ASTest.testListComplete = testList; + } + } } diff --git a/src/org/flex_pilot/events/Events.as b/src/org/flex_pilot/events/Events.as index d7efa82..8f0d07b 100644 --- a/src/org/flex_pilot/events/Events.as +++ b/src/org/flex_pilot/events/Events.as @@ -15,9 +15,27 @@ Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. */ package org.flex_pilot.events { + import flash.events.*; + + + import mx.controls.DataGrid; + import mx.controls.dataGridClasses.DataGridColumn; + import mx.core.DragSource; + import mx.core.mx_internal; + import mx.events.*; + import org.flex_pilot.events.*; - import flash.events.* - import mx.events.* + + + import util.DataGridUtil; + import util.IndexChangeUtil; + + FP::complete { + import util.AdvancedDataGridUtil; + import mx.controls.AdvancedDataGrid; + } + + public class Events { public function Events():void {} @@ -77,7 +95,10 @@ package org.flex_pilot.events { ['buttonDown', false], ['delta', 0] ]; + + var p:Object = Events.normalizeParams(defaults, args); + var ev:FPMouseEvent = new FPMouseEvent(type, p.bubbles, p.cancelable, p.localX, p.localY, p.relatedObject, p.ctrlKey, p.altKey, p.shiftKey, @@ -163,6 +184,242 @@ package org.flex_pilot.events { p.itemRenderer); obj.dispatchEvent(ev); } + + + + public static function triggerSliderEvent(obj:* , type:String , ...args):void{ + var defaults:Array=[ + ['bubbles',false], + ['cancelable',false], + ['thumbIndex',-1], + ['triggerEvent',null], + ['clickTarget',null], + ['keyCode',-1] + ]; + var p:Object = Events.normalizeParams(defaults, args); + var ev:FPSliderEvent=new FPSliderEvent(type, p.bubbles, p.cancelable, p.thumbIndex, p.value, p.triggerEvent, p.clickTarget, p.keyCode); + obj.dispatchEvent(ev); + + } + + public static function triggerCalendarLayoutChangeEvent(obj:* , type:String , ...args):void{ + var defaults:Array=[ + ['bubbles',false], + ['cancelable',false], + ['newDate',null], + ['triggerEvent',null] + ]; + + var p:Object=Events.normalizeParams(defaults, args); + + + var ev:FPCalendarLayoutChangeEvent=new FPCalendarLayoutChangeEvent(type, p.bubbles, p.cancelable, p.newDate, p.triggerEvent); + obj.dispatchEvent(ev); + + } + + public static function triggerDataGridEvent(obj:* , type:String , ...args):void{ + + var defaults:Array=[ + ['bubbles' , true], + ['cancelable' , false], + ['columnIndex',-1], + ['dataField',null], + ['rowIndex',-1], + ['reason',null], + ['itemRenderer',null], + ['localX',NaN], + ['newValue',null], + ['sortDescending',null] , + ['dir' , false] , + ['caseSensitivity' , false] + ]; + var p:Object=Events.normalizeParams(defaults, args); + + + var ev:FPDataGridEvent=new FPDataGridEvent(type , p.bubbles , p.cancelable , p.columnIndex , p.dataField , p.rowIndex , p.reason , p.itemRenderer ,p.localX); + switch(type){ + + case DataGridEvent.COLUMN_STRETCH : + DataGridUtil.columnStretch(obj , p.columnIndex , p.localX ); + break ; + + case DataGridEvent.ITEM_EDIT_END : + for(var i:* in obj.columns) + if(p.dataField==obj.columns[i].dataField){ + p.columns=i; + } + + + DataGridUtil.itemEdit(obj , p.rowIndex ,p.columnIndex, p.dataField , p.newValue); + break; + + case FPDataGridEvent.SORT_ASCENDING : + ev.preventDefault(); + DataGridUtil.sortGridOrder(obj , p.columnIndex , p.dir ,p.caseSensitivity); + break; + + case FPDataGridEvent.SORT_DESCENDING : + ev.preventDefault(); + DataGridUtil.sortGridOrder(obj , p.columnIndex , p.dir ,p.caseSensitivity); + break; + case DataGridEvent.HEADER_RELEASE : + ev.preventDefault(); + DataGridUtil.dgSort(obj , p.columnIndex , p.caseSensitivity ); + break; + + + + } + + + + obj.dispatchEvent(ev); + + + } + + FP::complete + public static function triggerAdvancedDataGridEvent(obj:* , type:String , ...args):void{ + var defaults:Array = [ + ['bubbles' , false] , + ['cancelable' , true] , + ['columnIndex' , -1], + ['dataField' , null ] , + ['rowIndex' , -1 ], + ['reason' , null ] , + ['localX' , NaN ], + ['multiColumnSort' ,false] , + ['removeColumnFromSort' , false] , + ['item' , null ], + ['triggerEvent' ,null] , + ['headerPart' , null] , + ['opening' , true], + ['caseSensitivity' , false] , + ['dir' , false] , + ['newValue' , null] + ]; + + var p:Object=Events.normalizeParams(defaults, args); + + + trace(p.rowIndex , p.columnIndex); + + // just a simple mechanism to handle the adg if it's dataProvider had been reset . this may cause a change in the value for the field 'mx_internal_uid' in dataProvider with respect to the original testcase + var found:Boolean=false; + if(p.item) + for(var i:* in obj.dataProvider){ + + found=true; + + for(var v:* in p.item){ + if(p.item[v]!=obj.dataProvider[i][v]&&v.indexOf('mx_internal_uid')==-1){ + found=false; + break; + } + } + + + if(p.item.length&&found){ + p.columnIndex=i; + p.item=obj.dataProvider[i]; + break; + } + } + + trace(p.rowIndex , p.columnIndex); + + var ev:FPAdvancedDataGridEvent = new FPAdvancedDataGridEvent( type , p.bubbles , p.cancelable , p.columnIndex , p.dataField , p.rowIndex , p.reason , obj.itemToItemRenderer(p.item) , p.localX , p.multiColumnSort , p.removeColumnFromSort , p.item , p.triggerEvent , p.headerPart); + + + + + switch(type){ + case AdvancedDataGridEvent.ITEM_OPENING : + ev.opening=p.opening; + break; + case AdvancedDataGridEvent.COLUMN_STRETCH : + AdvancedDataGridUtil.columnStretch(obj , p.columnIndex , p.localX); + break; + case AdvancedDataGridEvent.HEADER_RELEASE : + ev.preventDefault(); + AdvancedDataGridUtil.adgSort(obj , p.columnIndex , p.caseSensitivity ); + break; + case FPAdvancedDataGridEvent.SORT_ASCENDING : + ev.preventDefault(); + AdvancedDataGridUtil.sortGridOrder(obj , p.columnIndex , p.dir , p.caseSensitivity); + break; + + case FPAdvancedDataGridEvent.SORT_DESCENDING : + ev.preventDefault(); + AdvancedDataGridUtil.sortGridOrder(obj , p.columnIndex , p.dir , p.caseSensitivity); + break; + case AdvancedDataGridEvent.ITEM_EDIT_END : + ev.preventDefault(); + AdvancedDataGridUtil.itemEdit(obj , p.rowIndex , p.columnIndex , p.newValue); + break; + } + + } + + public static function triggerIndexChangedEvent(obj:* , type:String , ...args):void{ + + var defaults:Array = [ + ['bubbles' , false] , + ['cancelable' , false] , + ['relatedObject' , null] , + ['oldIndex' , -1] , + ['newIndex' , -1] , + ['triggerEvent' , null] + ]; + + var p:Object=Events.normalizeParams(defaults, args); + + var ev:FPIndexChangedEvent = new FPIndexChangedEvent(type , p.bubbles , p.cancelable , p.relatedObject , p.oldIndex , p.newIndex , p.triggerEvent); + + IndexChangeUtil.headerShift(obj , p.oldIndex , p.newIndex); + + obj.dispatchEvent(ev); + } + + public static function triggerDragEvent(obj:* , type:* , ...args):void{ + + var defaults:Array=[ + ['bubbles' , false] , + ['cancelable' , true], + ['dragInitiator' , null], + ['dragSource' , null ], + ['action' , null], + ['ctrlKey' ,false], + ['altKey' , false], + ['shiftKey' , false] , + ['stageX' , NaN ], + ['stageY' , NaN] , + ['localX' , NaN ] , + ['localY' , NaN] , + ['selectedItems' , null] + ]; + + var p:Object=Events.normalizeParams(defaults, args); + + var ds:DragSource=new DragSource; + + ds.addHandler( function(useDataField:Boolean=true):Array{ + return p.selectedItems; + } , "items"); + + + var e:FPDragEvent=new FPDragEvent(type ,p.bubbles , p.cancelable , p.dragInitiator , ds , p.action , p.ctrlKey , p.altKey , p.shiftKey ); + + e.localX=p.localX; + e.localY=p.localY; + + obj.dispatchEvent(e); + + } + + + } } diff --git a/src/org/flex_pilot/events/FPAdvancedDataGridEvent.as b/src/org/flex_pilot/events/FPAdvancedDataGridEvent.as new file mode 100644 index 0000000..180524b --- /dev/null +++ b/src/org/flex_pilot/events/FPAdvancedDataGridEvent.as @@ -0,0 +1,19 @@ +package org.flex_pilot.events +{ + import flash.events.Event; + + import mx.controls.listClasses.IListItemRenderer; + import mx.events.AdvancedDataGridEvent; + + public class FPAdvancedDataGridEvent extends AdvancedDataGridEvent + { + + public static const SORT_ASCENDING:String='sortAscending'; + public static const SORT_DESCENDING:String='sortDescending'; + + public function FPAdvancedDataGridEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, columnIndex:int=-1, dataField:String=null, rowIndex:int=-1, reason:String=null, itemRenderer:IListItemRenderer=null, localX:Number=NaN, multiColumnSort:Boolean=false, removeColumnFromSort:Boolean=false, item:Object=null, triggerEvent:Event=null, headerPart:String=null) + { + super(type, bubbles, cancelable, columnIndex, dataField, rowIndex, reason, itemRenderer, localX, multiColumnSort, removeColumnFromSort, item, triggerEvent, headerPart); + } + } +} \ No newline at end of file diff --git a/src/org/flex_pilot/events/FPCalendarLayoutChangeEvent.as b/src/org/flex_pilot/events/FPCalendarLayoutChangeEvent.as new file mode 100644 index 0000000..fb915d7 --- /dev/null +++ b/src/org/flex_pilot/events/FPCalendarLayoutChangeEvent.as @@ -0,0 +1,15 @@ +package org.flex_pilot.events +{ + import flash.events.Event; + + import mx.events.CalendarLayoutChangeEvent; + + public class FPCalendarLayoutChangeEvent extends CalendarLayoutChangeEvent + { + public function FPCalendarLayoutChangeEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, newDate:Date=null, triggerEvent:Event=null) + { + super(type, bubbles, cancelable, newDate, triggerEvent); + + } + } +} \ No newline at end of file diff --git a/src/org/flex_pilot/events/FPDataGridEvent.as b/src/org/flex_pilot/events/FPDataGridEvent.as new file mode 100644 index 0000000..27ed282 --- /dev/null +++ b/src/org/flex_pilot/events/FPDataGridEvent.as @@ -0,0 +1,16 @@ +package org.flex_pilot.events +{ + import mx.controls.listClasses.IListItemRenderer; + import mx.events.DataGridEvent; + + public class FPDataGridEvent extends DataGridEvent + { + + public static const SORT_ASCENDING:String='sortAscending'; + public static const SORT_DESCENDING:String='sortDescending'; + public function FPDataGridEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, columnIndex:int=-1, dataField:String=null, rowIndex:int=-1, reason:String=null, itemRenderer:IListItemRenderer=null, localX:Number=NaN) + { + super(type, bubbles, cancelable, columnIndex, dataField, rowIndex, reason, itemRenderer, localX); + } + } +} \ No newline at end of file diff --git a/src/org/flex_pilot/events/FPDragEvent.as b/src/org/flex_pilot/events/FPDragEvent.as new file mode 100644 index 0000000..9e3c008 --- /dev/null +++ b/src/org/flex_pilot/events/FPDragEvent.as @@ -0,0 +1,14 @@ +package org.flex_pilot.events +{ + import mx.core.DragSource; + import mx.core.IUIComponent; + import mx.events.DragEvent; + + public class FPDragEvent extends DragEvent + { + public function FPDragEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=true, dragInitiator:IUIComponent=null, dragSource:DragSource=null, action:String=null, ctrlKey:Boolean=false, altKey:Boolean=false, shiftKey:Boolean=false) + { + super(type, bubbles, cancelable, dragInitiator, dragSource, action, ctrlKey, altKey, shiftKey); + } + } +} \ No newline at end of file diff --git a/src/org/flex_pilot/events/FPIndexChangedEvent.as b/src/org/flex_pilot/events/FPIndexChangedEvent.as new file mode 100644 index 0000000..99e70c7 --- /dev/null +++ b/src/org/flex_pilot/events/FPIndexChangedEvent.as @@ -0,0 +1,15 @@ +package org.flex_pilot.events +{ + import flash.display.DisplayObject; + import flash.events.Event; + + import mx.events.IndexChangedEvent; + + public class FPIndexChangedEvent extends IndexChangedEvent + { + public function FPIndexChangedEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, relatedObject:DisplayObject=null, oldIndex:Number=-1, newIndex:Number=-1, triggerEvent:Event=null) + { + super(type, bubbles, cancelable, relatedObject, oldIndex, newIndex, triggerEvent); + } + } +} \ No newline at end of file diff --git a/src/org/flex_pilot/events/FPSliderEvent.as b/src/org/flex_pilot/events/FPSliderEvent.as new file mode 100644 index 0000000..6956206 --- /dev/null +++ b/src/org/flex_pilot/events/FPSliderEvent.as @@ -0,0 +1,20 @@ +/* +Author-MAheSH Gondi + +MASH +*/ + +package org.flex_pilot.events +{ + import flash.events.Event; + + import mx.events.SliderEvent; + + public class FPSliderEvent extends SliderEvent + { + public function FPSliderEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, thumbIndex:int=-1, value:Number=NaN, triggerEvent:Event=null, clickTarget:String=null, keyCode:int=-1) + { + super(type, bubbles, cancelable, thumbIndex, value, triggerEvent, clickTarget, keyCode); + } + } +} \ No newline at end of file diff --git a/src/util/AdvancedDataGridUtil.as b/src/util/AdvancedDataGridUtil.as new file mode 100755 index 0000000..a80aee2 --- /dev/null +++ b/src/util/AdvancedDataGridUtil.as @@ -0,0 +1,191 @@ +package util +{ + import flash.utils.describeType; + import flash.utils.setTimeout; + + import mx.collections.Sort; + import mx.collections.SortField; + import mx.controls.AdvancedDataGrid; + import mx.controls.AdvancedDataGridBaseEx; + import mx.controls.DataGrid; + import mx.controls.Text; + import mx.controls.TextInput; + import mx.controls.advancedDataGridClasses.AdvancedDataGridListData; + import mx.controls.listClasses.IDropInListItemRenderer; + import mx.core.IPropertyChangeNotifier; + import mx.events.AdvancedDataGridEvent; + + public class AdvancedDataGridUtil + { + public function AdvancedDataGridUtil() + { + } + + + public static function columnStretch(obj:* , columnIndex:Number , localX:Number):void{ + + var colArray:Array=obj.columns; + + if(columnIndex bounds.right ? - (bounds.right - dr.width) : dragX; - // Left bound - dragY = (dragY + dr.height) > bounds.bottom ? - (bounds.bottom - dr.height) : dragY; - } - dr.x = Math.round(dragX); - dr.y = Math.round(dragY); - } - } - } -} - - +/* +Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. + + Licensed 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. +*/ + +package util { + import flash.display.Sprite; + import flash.events.MouseEvent; + import flash.geom.Point; + import flash.geom.Rectangle; + + /* + * Replacement for AS3 Sprite startDrag/stopDrag + * using only DOM events. + * This allows the drag/drop action to be automated + * using FlexPilot or other automation frameworks + * that rely on simulated user events + */ + public class DOMEventDrag { + // The Sprite instance to drag + private static var dragSprite:Sprite; + // Pointer offset from top-left corner of the Sprite + private static var offset:Point; + // Lock pointer to the center of the Sprite or not + private static var lockCenter:Boolean; + // Drag constraints, if any, for the drag operation + private static var bounds:Rectangle; + + // For docs on the built-in method, see: + // http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Sprite.html#startDrag%28%29 + public static function startDrag(spr:Sprite, + lockCenter:Boolean = false, bounds:Rectangle = null):void { + DOMEventDrag.dragSprite = spr; + DOMEventDrag.lockCenter = lockCenter; + DOMEventDrag.bounds = bounds; + // Event listener for mouse move on the stage + // routed to private doDrag method + spr.stage.addEventListener(MouseEvent.MOUSE_MOVE, DOMEventDrag.doDrag); + } + + // For docs on the built-in method, see: + // http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Sprite.html#stopDrag%28%29 + public static function stopDrag(spr:Sprite):void { + // Remove the event listener on the stage + DOMEventDrag.dragSprite.stage.removeEventListener( + MouseEvent.MOUSE_MOVE, + DOMEventDrag.doDrag); + // Remove the dragSprite and the saved offset + DOMEventDrag.dragSprite = null; + DOMEventDrag.offset = null; + } + + private static function doDrag(e:MouseEvent):void { + var dr:Sprite = DOMEventDrag.dragSprite; + // If there's a dragSprite, drag that mofo + // The dragSprite is removed in stopDrag + if (dr) { + var dragX:int; + var dragY:int; + var coordsAbs:Point = new Point(e.stageX, e.stageY); + // Get the local coors of the sprite's container + var coordsLocal:Point = dr.parent.globalToLocal(coordsAbs); + // Since we don't get access to the inital mouse click, + // calculate the offset on the very first mouse move. + // Once the offset is set, blow by this every time. + // stopDrag clears the saved offset until the next drag + if (!DOMEventDrag.offset) { + // Lock the cursor to the center of the Sprite + // Set in the constructor -- defaults to false + if (DOMEventDrag.lockCenter) { + var offX:int = dr.width / 2; + var offY:int = dr.height / 2; + DOMEventDrag.offset = new Point(offX, offY); + } + // Otherwise remember where the click happened, + // and preserve the offset + else { + DOMEventDrag.offset = new Point(coordsLocal.x - dr.x, + coordsLocal.y - dr.y); + } + } + // Adjust the x/y by the offset -- either pointer position + // or to center of the Sprite + dragX = coordsLocal.x - DOMEventDrag.offset.x; + dragY = coordsLocal.y - DOMEventDrag.offset.y; + // Observe any drag constraints + var bounds:Rectangle = DOMEventDrag.bounds; + if (bounds) { + // Left bound + dragX = dragX < bounds.left ? + bounds.left : dragX; + // Top bound + dragY = dragY < bounds.top ? + bounds.top : dragY; + // Right bound + dragX = (dragX + dr.width) > bounds.right ? + (bounds.right - dr.width) : dragX; + // Left bound + dragY = (dragY + dr.height) > bounds.bottom ? + (bounds.bottom - dr.height) : dragY; + } + dr.x = Math.round(dragX); + dr.y = Math.round(dragY); + } + } + } +} + + diff --git a/src/util/DataGridUtil.as b/src/util/DataGridUtil.as new file mode 100755 index 0000000..d54b9e9 --- /dev/null +++ b/src/util/DataGridUtil.as @@ -0,0 +1,132 @@ +package util +{ + import mx.collections.ICollectionView; + import mx.collections.Sort; + import mx.collections.SortField; + import mx.controls.DataGrid; + import mx.controls.TextInput; + import mx.controls.dataGridClasses.DataGridColumn; + import mx.controls.listClasses.IDropInListItemRenderer; + import mx.events.FlexEvent; + import mx.events.IndexChangedEvent; + + + public class DataGridUtil + { + public function DataGridUtil() + { + } + + public static function columnStretch(obj:* , columnIndex:Number , localX:Number):void{ + + var colArray:Array=obj.columns; + + if(columnIndex + + + + + + + + +
+
+ + diff --git a/tests/FlexPilotTest.mxml b/tests/FlexPilotTest.mxml new file mode 100755 index 0000000..6a0bfe9 --- /dev/null +++ b/tests/FlexPilotTest.mxml @@ -0,0 +1,76 @@ + + + + + + + =2){ + topPanel.height=2; + } + } + + + + + + + + protected function application1_creationCompleteHandler(event:FlexEvent):void + { + + trace("intializing"); + FPBootstrap.flex_pilotLibPath='FlexPilot.swf'; + FPBootstrap.init(this); + } + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/TestAccordion.html b/tests/TestAccordion.html new file mode 100755 index 0000000..21b5bcf --- /dev/null +++ b/tests/TestAccordion.html @@ -0,0 +1,44 @@ + + + + + + + + + + +
+
+ + diff --git a/tests/TestAccordion.mxml b/tests/TestAccordion.mxml old mode 100644 new mode 100755 index 91fe16b..068f0eb --- a/tests/TestAccordion.mxml +++ b/tests/TestAccordion.mxml @@ -1,36 +1,97 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + Christina Coenraets + 555-219-2270 + http://www.fictitious.com + true + + + Joanne Wall + 555-219-2012 + jwall@fictitious.com + true + + + Maurice Smith + 555-219-2012 + maurice@fictitious.com + false + + + Mary Jones + 555-219-2000 + mjones@fictitious.com + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/TestApp.mxml b/tests/TestApp.mxml old mode 100644 new mode 100755 index b672451..fd5bb3f --- a/tests/TestApp.mxml +++ b/tests/TestApp.mxml @@ -1,29 +1,29 @@ - - - - - - - - + + + + + + + + diff --git a/tests/TestAppCode.as b/tests/TestAppCode.as old mode 100644 new mode 100755 index 9b0a63d..12a26fe --- a/tests/TestAppCode.as +++ b/tests/TestAppCode.as @@ -1,144 +1,144 @@ -/* -Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. - - Licensed 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. -*/ - -package { - import mx.core.Application; - import flash.display.MovieClip; - import flash.events.* - import mx.controls.* - import mx.containers.Panel - import mx.events.* - import flash.utils.*; - import flash.net.URLRequest; - import flash.display.Stage; - import flash.display.Sprite; - import flash.geom.Rectangle; - import util.DOMEventDrag; - import flash.display.Sprite; - import flash.geom.Point; - import flash.external.ExternalInterface; - import org.flex_pilot.FPBootstrap; - - public class TestAppCode extends MovieClip { - - public var publicInt:int = 2112; - public var publicString:String = 'Geddy Lee'; - public var publicArray:Array = ['By-Tor', 'Snow Dog']; - - private var stg:Stage; - private var spr:Sprite = new Sprite(); - private var draggable:Sprite; - private var context:*; - private var elems:Object = {}; - private var foo:Sprite; - - public function init(ctxt:Application):void { - context = ctxt; - stg = context.stage; - - // Panel - var panel:Panel = new Panel(); - context.addChild(panel); - panel.id = 'mainPanel'; - panel.title = "FlexPilot Flash Tests"; - - // TextArea - var txtArea:TextArea = new TextArea(); - txtArea.name = 'testTextArea'; - panel.addChild(txtArea); - elems.txtArea = txtArea; - - // Button - var button:Button = new Button(); - button.id = 'howdyButton'; - button.label = 'Howdy'; - panel.addChild(button); - - // Text input - var txtInput:TextInput = new TextInput(); - txtInput.name = 'testTextInput'; - panel.addChild(txtInput); - txtInput.htmlText = 'This is a test.'; - elems.txtInput = txtInput - - var subPanel:Panel = new Panel(); - panel.addChild(subPanel); - subPanel.id = 'subPanel'; - - // Plain text field - var txtField:Text = new Text(); - txtField.name = 'testText'; - subPanel.addChild(txtField); - txtField.htmlText = 'This is some test text. This is a test link'; - - // Combo box (select) - var items:Array = [ - { - dude: 'Geddy', - data: 'bass' - }, - { - dude: 'Neil', - data: 'drums' - }, - { - dude: 'Alex', - data: 'guitar' - } - ]; - var box:ComboBox = new ComboBox(); - box.labelField = 'dude'; - box.name = 'comboTest'; - box.dataProvider = items; - box.selectedItem = items[1]; - subPanel.addChild(box); - - spr.name = 'dragSprite'; - spr.graphics.clear() - spr.graphics.beginFill(0x00ff00); - spr.graphics.drawRect(0,0,100,100); - stg.addChild(spr); - - spr.addEventListener(MouseEvent.MOUSE_DOWN, beginDrag); - stg.addEventListener(MouseEvent.MOUSE_UP, endDrag); - - context.doubleClickEnabled = true; - - FPBootstrap.flex_pilotLibPath = 'FlexPilot.swf'; - FPBootstrap.init(context); - - } - private function evHandler(e:Event):void { - var targ:* = e.target; - trace(e.toString()); - trace(e.target.toString()); - trace(getQualifiedClassName(e.target)); - } - - private function beginDrag(e:MouseEvent):void { - if (e.target.name == 'dragSprite') { - DOMEventDrag.startDrag(spr); - //spr.startDrag(); - } - } - private function endDrag(e:MouseEvent):void { - if (e.target.name == 'dragSprite') { - DOMEventDrag.stopDrag(spr); - } - //spr.stopDrag(); - } - } -} +/* +Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. + + Licensed 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. +*/ + +package { + import mx.core.Application; + import flash.display.MovieClip; + import flash.events.* + import mx.controls.* + import mx.containers.Panel + import mx.events.* + import flash.utils.*; + import flash.net.URLRequest; + import flash.display.Stage; + import flash.display.Sprite; + import flash.geom.Rectangle; + import util.DOMEventDrag; + import flash.display.Sprite; + import flash.geom.Point; + import flash.external.ExternalInterface; + import org.flex_pilot.FPBootstrap; + + public class TestAppCode extends MovieClip { + + public var publicInt:int = 2112; + public var publicString:String = 'Geddy Lee'; + public var publicArray:Array = ['By-Tor', 'Snow Dog']; + + private var stg:Stage; + private var spr:Sprite = new Sprite(); + private var draggable:Sprite; + private var context:*; + private var elems:Object = {}; + private var foo:Sprite; + + public function init(ctxt:Application):void { + context = ctxt; + stg = context.stage; + + // Panel + var panel:Panel = new Panel(); + context.addChild(panel); + panel.id = 'mainPanel'; + panel.title = "FlexPilot Flash Tests"; + + // TextArea + var txtArea:TextArea = new TextArea(); + txtArea.name = 'testTextArea'; + panel.addChild(txtArea); + elems.txtArea = txtArea; + + // Button + var button:Button = new Button(); + button.id = 'howdyButton'; + button.label = 'Howdy'; + panel.addChild(button); + + // Text input + var txtInput:TextInput = new TextInput(); + txtInput.name = 'testTextInput'; + panel.addChild(txtInput); + txtInput.htmlText = 'This is a test.'; + elems.txtInput = txtInput + + var subPanel:Panel = new Panel(); + panel.addChild(subPanel); + subPanel.id = 'subPanel'; + + // Plain text field + var txtField:Text = new Text(); + txtField.name = 'testText'; + subPanel.addChild(txtField); + txtField.htmlText = 'This is some test text. This is a test link'; + + // Combo box (select) + var items:Array = [ + { + dude: 'Geddy', + data: 'bass' + }, + { + dude: 'Neil', + data: 'drums' + }, + { + dude: 'Alex', + data: 'guitar' + } + ]; + var box:ComboBox = new ComboBox(); + box.labelField = 'dude'; + box.name = 'comboTest'; + box.dataProvider = items; + box.selectedItem = items[1]; + subPanel.addChild(box); + + spr.name = 'dragSprite'; + spr.graphics.clear() + spr.graphics.beginFill(0x00ff00); + spr.graphics.drawRect(0,0,100,100); + stg.addChild(spr); + + spr.addEventListener(MouseEvent.MOUSE_DOWN, beginDrag); + stg.addEventListener(MouseEvent.MOUSE_UP, endDrag); + + context.doubleClickEnabled = true; + + FPBootstrap.flex_pilotLibPath = 'FlexPilot.swf'; + FPBootstrap.init(context); + + } + private function evHandler(e:Event):void { + var targ:* = e.target; + trace(e.toString()); + trace(e.target.toString()); + trace(getQualifiedClassName(e.target)); + } + + private function beginDrag(e:MouseEvent):void { + if (e.target.name == 'dragSprite') { + DOMEventDrag.startDrag(spr); + //spr.startDrag(); + } + } + private function endDrag(e:MouseEvent):void { + if (e.target.name == 'dragSprite') { + DOMEventDrag.stopDrag(spr); + } + //spr.stopDrag(); + } + } +} diff --git a/tests/TestBar.as b/tests/TestBar.as old mode 100644 new mode 100755 index d43a4a7..0f38ce6 --- a/tests/TestBar.as +++ b/tests/TestBar.as @@ -1,9 +1,9 @@ -package { - import org.flex_pilot.TestCase; - - public class TestBar extends TestCase { - public function testUiop():void { - } - } -} - +package { + import org.flex_pilot.TestCase; + + public class TestBar extends TestCase { + public function testUiop():void { + } + } +} + diff --git a/tests/TestControlBar.html b/tests/TestControlBar.html new file mode 100755 index 0000000..c6285cf --- /dev/null +++ b/tests/TestControlBar.html @@ -0,0 +1,44 @@ + + + + + + + + + + +
+
+ + diff --git a/tests/TestControlBar.mxml b/tests/TestControlBar.mxml new file mode 100755 index 0000000..a769966 --- /dev/null +++ b/tests/TestControlBar.mxml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/accordion.html b/tests/TestDemo.html old mode 100644 new mode 100755 similarity index 93% rename from tests/accordion.html rename to tests/TestDemo.html index 87cc8f9..57d6334 --- a/tests/accordion.html +++ b/tests/TestDemo.html @@ -1,68 +1,68 @@ - - - - - - - - - - -
-

Testin' Flash

-
-
Here's a text input
-
-
 
-
Here's a select
-
- -
-
 
-
Here are some radio buttons
-
-  Geddy -  Neil -  Alex -
-
-
-
-
- - + + + + + + + + + + +
+

Testin' Flash

+
+
Here's a text input
+
+
 
+
Here's a select
+
+ +
+
 
+
Here are some radio buttons
+
+  Geddy +  Neil +  Alex +
+
+
+
+
+ + diff --git a/tests/TestFoo.as b/tests/TestFoo.as old mode 100644 new mode 100755 index db3b9a1..741ba19 --- a/tests/TestFoo.as +++ b/tests/TestFoo.as @@ -1,69 +1,69 @@ -package { - import org.flex_pilot.TestCase; - public class TestFoo extends TestCase { - public var order:Array = ['testClick', 'testClickTimeout', 'testWaitCondition', 'testWaitConditionTimeout', - 'testWaitSleep', 'testAssertDisplayObject', 'testWaitDisplayObject', 'testAssertEqualsString', - 'testAssertEqualsNumber', 'testAppPublicInt', 'testAppPublicString', 'testAppPublicArray']; - - public function setup():void { - } - public function testClick():void { - controller.click({id: 'howdyButton'}); - } - public function testClickTimeout():void { - controller.click({id: 'howdyButton', timeout: 3000}); - } - public function testWaitCondition():void { - var now:Date = new Date(); - var nowTime:Number = now.getTime(); - var thenTime:Number = nowTime + 5000; // Five seconds from now - waits.forCondition({test: function ():Boolean { - var dt:Date = new Date(); - var dtTime:Number = dt.getTime(); - // Wait until the current date is greater - // the thenTime, set above - return (dtTime > thenTime); - }}); - } - public function testWaitConditionTimeout():void { - waits.forCondition({test: function ():Boolean { - return false; - }, timeout: 3000}); - } - public function testWaitSleep():void { - waits.sleep({milliseconds: 5000}); - } - public function testAssertDisplayObject():void { - asserts.assertDisplayObject({id: 'mainPane'}); - } - public function testWaitDisplayObject():void { - waits.forDisplayObject({id: 'mainPanel', timeout: 5000}); - } - public function testAssertEqualsString():void { - var foo:String = 'foo'; - asserts.assertEquals('foo', foo); - } - public function testAssertEqualsNumber():void { - var num:int = 2111; - asserts.assertEquals(2112, num); - } - - // Test some public properties in the main Flex app class - public function testAppPublicInt():void { - var num:int = context.testAppCode.publicInt; - asserts.assertEquals(2112, num); - } - public function testAppPublicString():void { - var str:String = context.testAppCode.publicString; - asserts.assertEquals('Geddy Lee', str); - } - public function testAppPublicArray():void { - var arr:Array = context.testAppCode.publicArray; - asserts.assertEquals('Snow Dog', arr[1]); - } - - public function teardown():void { - } - } -} - +package { + import org.flex_pilot.TestCase; + public class TestFoo extends TestCase { + public var order:Array = ['testClick', 'testClickTimeout', 'testWaitCondition', 'testWaitConditionTimeout', + 'testWaitSleep', 'testAssertDisplayObject', 'testWaitDisplayObject', 'testAssertEqualsString', + 'testAssertEqualsNumber', 'testAppPublicInt', 'testAppPublicString', 'testAppPublicArray']; + + public function setup():void { + } + public function testClick():void { + controller.click({id: 'howdyButton'}); + } + public function testClickTimeout():void { + controller.click({id: 'howdyButton', timeout: 3000}); + } + public function testWaitCondition():void { + var now:Date = new Date(); + var nowTime:Number = now.getTime(); + var thenTime:Number = nowTime + 5000; // Five seconds from now + waits.forCondition({test: function ():Boolean { + var dt:Date = new Date(); + var dtTime:Number = dt.getTime(); + // Wait until the current date is greater + // the thenTime, set above + return (dtTime > thenTime); + }}); + } + public function testWaitConditionTimeout():void { + waits.forCondition({test: function ():Boolean { + return false; + }, timeout: 3000}); + } + public function testWaitSleep():void { + waits.sleep({milliseconds: 5000}); + } + public function testAssertDisplayObject():void { + asserts.assertDisplayObject({id: 'mainPane'}); + } + public function testWaitDisplayObject():void { + waits.forDisplayObject({id: 'mainPanel', timeout: 5000}); + } + public function testAssertEqualsString():void { + var foo:String = 'foo'; + asserts.assertEquals('foo', foo); + } + public function testAssertEqualsNumber():void { + var num:int = 2111; + asserts.assertEquals(2112, num); + } + + // Test some public properties in the main Flex app class + public function testAppPublicInt():void { + var num:int = context.testAppCode.publicInt; + asserts.assertEquals(2112, num); + } + public function testAppPublicString():void { + var str:String = context.testAppCode.publicString; + asserts.assertEquals('Geddy Lee', str); + } + public function testAppPublicArray():void { + var arr:Array = context.testAppCode.publicArray; + asserts.assertEquals('Snow Dog', arr[1]); + } + + public function teardown():void { + } + } +} + diff --git a/tests/TestWildcards.html b/tests/TestWildcards.html new file mode 100755 index 0000000..4ee0268 --- /dev/null +++ b/tests/TestWildcards.html @@ -0,0 +1,52 @@ + + + + + + + + + + +
+

Testin' Wildcards

+
+
+
+
+
flexType
+
id=testApp
+
text=mine,chain=id:testApp/name:HBox*/name:HBox*/name:VBox*/name:HBox*/name:TextInput*/name:UITextField*
+
+ + diff --git a/tests/TestWildcards.mxml b/tests/TestWildcards.mxml new file mode 100755 index 0000000..8fa85cb --- /dev/null +++ b/tests/TestWildcards.mxml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/build.py b/tests/build.py index 76c3ee8..9f0a904 100755 --- a/tests/build.py +++ b/tests/build.py @@ -6,7 +6,7 @@ import shutil # Location of compiler -MXMLC_PATH = 'mxmlc -debug -verbose-stacktraces -incremental=true -compiler.strict -compiler.show-actionscript-warnings -static-link-runtime-shared-libraries=true' +MXMLC_PATH = 'mxmlc -debug -verbose-stacktraces -incremental=true -compiler.strict -compiler.show-actionscript-warnings -static-link-runtime-shared-libraries=true -define=FP::complete,false' # For replacing .as with .swf as_re = re.compile('\.as$|\.mxml$') @@ -20,6 +20,21 @@ def accordion(): cmd = MXMLC_PATH + ' -source-path=. -source-path+=../src ./TestAccordion.mxml -o ./TestAccordion.swf' print cmd os.system(cmd) + +def wildcards(): + cmd = MXMLC_PATH + ' -source-path=. -source-path+=../src ./TestWildcards.mxml -o ./TestWildcards.swf' + print cmd + os.system(cmd) + +def controlbar(): + cmd = MXMLC_PATH + ' -source-path=. -source-path+=../src ./TestControlBar.mxml -o ./TestControlBar.swf' + print cmd + os.system(cmd) + +def fptestapp(): + cmd = MXMLC_PATH + ' -source-path=. -source-path+=../src ./FlexPilotTest.mxml -o ./FlexPilotTest.swf' + print cmd + os.system(cmd) def tests(): for root, dirs, file_list in os.walk('./'): @@ -46,7 +61,7 @@ def parse_opts(): parser = optparse.OptionParser() parser.add_option('-t', '--target', dest='target', help='build TARGET (tests/app/all/clean, default is all)', - metavar='TARGET', choices=('tests', 'app', 'all', 'clean'), default='all') + metavar='TARGET', choices=('tests', 'app', 'all', 'clean', 'accordion', 'wildcards', 'controlbar'), default='all') opts, args = parser.parse_args() return opts, args @@ -60,10 +75,17 @@ def main(o, a): app() elif target == 'accordion': accordion() + elif target == 'wildcards': + wildcards() + elif target == 'controlbar': + controlbar() # Build everything, natch elif target == 'all': app() accordion() + wildcards() + fptestapp() + controlbar() tests() # Clean out any swfs in the directory elif target == 'clean': diff --git a/tests/components/Components.mxml b/tests/components/Components.mxml new file mode 100755 index 0000000..b624ea5 --- /dev/null +++ b/tests/components/Components.mxml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/components/Home.mxml b/tests/components/Home.mxml new file mode 100755 index 0000000..e5e9e6d --- /dev/null +++ b/tests/components/Home.mxml @@ -0,0 +1,171 @@ + + + + + + + =0){ + leftPanel.width=0; + } + } + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Embed(source='../style/darkroom.swf',symbol='finial') + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • Get Started!: http://wiki.github.com/mde/flex-pilot/getting-started
  • +
  • Example Project: http://github.com/downloads/mde/flex-pilot/fp_demo.zip
  • +
  • Selenium IDE Extension: http://github.com/admc/flex-pilot-x
  • + + + + ]]> +
    +
    + + +
    + + + + + + + + + + + http://www.adobe.com/devnet/flex/samples/flex_store/ +
    Download the source code for flexstore and Flex-Pilot . Also download the binary for FlexPilot from http://github.com/downloads/mde/flex-pilot/FlexPilot.swf ino flexstore directory . +
    Extracted the demo app to my desktop, in a folder named ‘flexstore’ . +
    Open main mxml file, flexstore.mxml in an editor . +
    Add the applicationComplete="init();" to the mx:Application tag . +
    Add import for FlexPilot bootstrapper : import org.flex_pilot.FPBootstrap; +
    Add the following lines of code : +
    private function init():void {
    +							FPBootstrap.flex_pilotLibPath = 'FlexPilot.swf';
    +							FPBootstrap.init(stage);
    +							}
    +							
    +
    Build it . +
    FlexPilot happens to have a build script which I modified, but I tested it by running the following on the command line: mxmlc -source-path=. -source-path+=../flex-pilot/src flexstore.mxml +
    Keep in mind that the -source-path stuff just tells the compiler to look in that flex-pilot directory on the desktop to find the import of the boot strapper that we added. + ]]> +
    +
    + + +
    + + + +
    + + + + + + + +
    + + + +
    + + + + + +
    diff --git a/tests/components/TestSamples.mxml b/tests/components/TestSamples.mxml new file mode 100755 index 0000000..46d881a --- /dev/null +++ b/tests/components/TestSamples.mxml @@ -0,0 +1,529 @@ + + + + + + + =0){ + leftPanel.width=0; + } + } + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Embed(source='../style/darkroom.swf',symbol='finial') + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/components/adgComponent.mxml b/tests/components/adgComponent.mxml new file mode 100755 index 0000000..75f7a67 --- /dev/null +++ b/tests/components/adgComponent.mxml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/images/logo.png b/tests/images/logo.png new file mode 100755 index 0000000..46dbe5d Binary files /dev/null and b/tests/images/logo.png differ diff --git a/tests/images/logo2.png b/tests/images/logo2.png new file mode 100755 index 0000000..780c7cc Binary files /dev/null and b/tests/images/logo2.png differ diff --git a/tests/index.html b/tests/index.html index b64a3ab..bc2b4dc 100644 --- a/tests/index.html +++ b/tests/index.html @@ -1,68 +1,21 @@ - - - - - - - - - - -
    -

    Testin' Flash

    -
    -
    Here's a text input
    -
    -
     
    -
    Here's a select
    -
    - -
    -
     
    -
    Here are some radio buttons
    -
    -  Geddy -  Neil -  Alex -
    -
    -
    -
    -
    - + + + + + + FlexPilot Test Index + + + + + +

    FlexPilot Testing Apps

    +
      +
    • Demo App
    • +
    • DataGrid Sampler App
    • +
    • Accordion
    • +
    • Wildcards
    • +
    • ControlBar
    • + diff --git a/tests/style/darkroom.css b/tests/style/darkroom.css new file mode 100755 index 0000000..6545fae --- /dev/null +++ b/tests/style/darkroom.css @@ -0,0 +1,1374 @@ +/* +/////////////////////////////////////////////////////////////////////////////// +// +// Darkroom theme by Juan Sanchez. Based on instructions from Adobe and +// inspired by Adobe Lightroom. For more themes check out http://www.scalenine.com +// +/////////////////////////////////////////////////////////////////////////////// +*/ + +@font-face { + src: url(myriad.swf); + fontFamily: "Myriad Pro"; + fontStyle: normal; + fontWeight: normal; +} + +@font-face { + src: url(myriad.swf); + fontFamily: "Myriad Pro Bold"; + fontStyle: normal; + fontWeight: normal; +} + + + +/* +//------------------------------ +// Global +//------------------------------ +*/ + +global +{ + /* themeColor */ + themeColor: #666666; + fontFamily: "Myriad Pro"; + fontWeight: normal; + fontSize:11; + color:#ffffff; + textRollOverColor:#666666; + textSelectedColor:#1e1e1e; + disabledColor:#1e1e1e; +} + +/* +//------------------------------ +// Accordion +//------------------------------ +*/ +Accordion +{ + borderStyle:solid; + borderColor:#000000; + borderThickness:1; + backgroundColor:#3e3e3e; + fontWeight:normal; + fontSize:11; + /*backgroundImage: Embed(source="darkroom.swf", symbol="lightGrey_Bg"); + backgroundSize:"100%";*/ + color: #aaaaaa; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + disabledColor:#111111; +} + +/* +//------------------------------ +// AccordionHeader +//------------------------------ +*/ +AccordionHeader +{ + + disabledSkin: Embed(source="darkroom.swf", symbol="AccordionHeader_disabledSkin"); + downSkin: Embed(source="darkroom.swf", symbol="AccordionHeader_downSkin"); + overSkin: Embed(source="darkroom.swf", symbol="AccordionHeader_overSkin"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="AccordionHeader_disabledSkin"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="AccordionHeader_downSkin"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="AccordionHeader_overSkin"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="AccordionHeader_selectedSkin"); + upSkin: Embed(source="darkroom.swf", symbol="AccordionHeader_upSkin"); + color: #aaaaaa; + textRollOverColor: #ffffff; + textSelectedColor:#444444; + disabledColor:#111111; + selectedColor:#ffffff; +} + +/* +//------------------------------ +// Application +//------------------------------ +*/ +Application +{ + backgroundColors: #000000,#3f3f3f; + backgroundSize: "100%"; +} + +/* +//------------------------------ +// Backgrounds +//------------------------------ +*/ +.darkGreyBg +{ + backgroundImage: Embed(source="darkroom.swf", symbol="darkGrey_Bg"); + backgroundSize: "100%"; + borderStyle:none; +} + +.darkGreyInsetBg +{ + backgroundImage: Embed(source="darkroom.swf", symbol="darkGreyInset_Bg"); + backgroundSize: "100%"; + borderStyle:none; +} + +.darkGreyShadowBg +{ + backgroundImage: Embed(source="darkroom.swf", symbol="darkGreyShadow_Bg"); + backgroundSize: "100%"; + borderStyle:none; +} + +.lightGreyBg +{ + backgroundImage: Embed(source="darkroom.swf", symbol="lightGrey_Bg"); + backgroundSize: "100%"; + borderStyle:none; +} + +.lightGreyBevelBg +{ + backgroundImage: Embed(source="darkroom.swf", symbol="lightGreyBevel_Bg"); + backgroundSize: "100%"; + borderStyle:none; +} + +.centerLightGreyBg +{ + backgroundImage: Embed(source="darkroom.swf", symbol="centerLightGrey_Bg"); + backgroundSize: "100%"; + borderStyle:none; +} + +.sortBarBg +{ + backgroundImage: Embed(source="darkroom.swf", symbol="sortBarBg"); + backgroundSize: "100%"; + borderStyle:none; +} + +.lightBoxBg +{ + backgroundImage: Embed(source="darkroom.swf", symbol="lightBox_Bg"); + backgroundSize: "100%"; + borderStyle:none; +} + +.linesBg +{ + backgroundImage: Embed(source="darkroom.swf", symbol="lines_Bg"); + backgroundSize: "100%"; + borderStyle:none; +} + +/* +//------------------------------ +// Buttons +//------------------------------ +*/ +Button +{ + disabledSkin: Embed(source="darkroom.swf", symbol="Button_disabledSkin"); + downSkin: Embed(source="darkroom.swf", symbol="Button_downSkin"); + overSkin: Embed(source="darkroom.swf", symbol="Button_overSkin"); + upSkin: Embed(source="darkroom.swf", symbol="Button_upSkin"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="Button_disabledSkin"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="Button_upSkin"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="Button_overSkin"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="Button_downSkin"); + color: #aaaaaa; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + disabledColor:#111111; + fontFamily:"Myriad Pro"; + fontWeight:normal; +} + +.clearButton +{ + disabledSkin: Embed(source="darkroom.swf", symbol="clear"); + downSkin: Embed(source="darkroom.swf", symbol="clear"); + overSkin: Embed(source="darkroom.swf", symbol="clear"); + upSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="clear"); + color: #808080; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + textDisabledColor: #ffffff; + fontWeight: "normal"; +} + +.sectionButton +{ + disabledSkin: Embed(source="darkroom.swf", symbol="clear"); + downSkin: Embed(source="darkroom.swf", symbol="clear"); + overSkin: Embed(source="darkroom.swf", symbol="clear"); + upSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="clear"); + disabledIcon: Embed(source="darkroom.swf", symbol="sectionArrowUp"); + downIcon: Embed(source="darkroom.swf", symbol="sectionArrowUp"); + overIcon: Embed(source="darkroom.swf", symbol="sectionArrowUp"); + upIcon: Embed(source="darkroom.swf", symbol="sectionArrowUp"); + selectedDisabledIcon: Embed(source="darkroom.swf", symbol="sectionArrowDown"); + selectedDownIcon: Embed(source="darkroom.swf", symbol="sectionArrowDown"); + selectedOverIcon: Embed(source="darkroom.swf", symbol="sectionArrowDown"); + selectedUpIcon: Embed(source="darkroom.swf", symbol="sectionArrowDown"); + color: #999999; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + textDisabledColor: #1e1e1e; + fontWeight: "normal"; + fontSize:16; + horizontalGap:2; + textAlign:left; +} + +.sectionButtonRight +{ + disabledSkin: Embed(source="darkroom.swf", symbol="clear"); + downSkin: Embed(source="darkroom.swf", symbol="clear"); + overSkin: Embed(source="darkroom.swf", symbol="clear"); + upSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="clear"); + disabledIcon: Embed(source="darkroom.swf", symbol="sectionArrowFlip"); + downIcon: Embed(source="darkroom.swf", symbol="sectionArrowFlip"); + overIcon: Embed(source="darkroom.swf", symbol="sectionArrowFlip"); + upIcon: Embed(source="darkroom.swf", symbol="sectionArrowFlip"); + selectedDisabledIcon: Embed(source="darkroom.swf", symbol="sectionArrowDown"); + selectedDownIcon: Embed(source="darkroom.swf", symbol="sectionArrowDown"); + selectedOverIcon: Embed(source="darkroom.swf", symbol="sectionArrowDown"); + selectedUpIcon: Embed(source="darkroom.swf", symbol="sectionArrowDown"); + color: #999999; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + textDisabledColor: #1e1e1e; + fontWeight: "normal"; + fontSize:16; + horizontalGap:2; + textAlign:right; + /* Set labelPlacement:left on any buttons in MXML using this style to get the icon on the right*/ +} + +.collapseUp +{ + disabledSkin: Embed(source="darkroom.swf", symbol="clear"); + downSkin: Embed(source="darkroom.swf", symbol="clear"); + overSkin: Embed(source="darkroom.swf", symbol="clear"); + upSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="clear"); + disabledIcon: Embed(source="darkroom.swf", symbol="collapseArrowUp_Up"); + downIcon: Embed(source="darkroom.swf", symbol="collapseArrowUp_Over"); + overIcon: Embed(source="darkroom.swf", symbol="collapseArrowUp_Over"); + upIcon: Embed(source="darkroom.swf", symbol="collapseArrowUp_Up"); + selectedDisabledIcon: Embed(source="darkroom.swf", symbol="collapseArrowDownSelected_Up"); + selectedDownIcon: Embed(source="darkroom.swf", symbol="collapseArrowDownSelected_Over"); + selectedOverIcon: Embed(source="darkroom.swf", symbol="collapseArrowDownSelected_Over"); + selectedUpIcon: Embed(source="darkroom.swf", symbol="collapseArrowDownSelected_Up"); +} + +.collapseDown +{ + disabledSkin: Embed(source="darkroom.swf", symbol="clear"); + downSkin: Embed(source="darkroom.swf", symbol="clear"); + overSkin: Embed(source="darkroom.swf", symbol="clear"); + upSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="clear"); + disabledIcon: Embed(source="darkroom.swf", symbol="collapseArrowDown_Up"); + downIcon: Embed(source="darkroom.swf", symbol="collapseArrowDown_Over"); + overIcon: Embed(source="darkroom.swf", symbol="collapseArrowDown_Over"); + upIcon: Embed(source="darkroom.swf", symbol="collapseArrowDown_Up"); + selectedDisabledIcon: Embed(source="darkroom.swf", symbol="collapseArrowUpSelected_Up"); + selectedDownIcon: Embed(source="darkroom.swf", symbol="collapseArrowUpSelected_Over"); + selectedOverIcon: Embed(source="darkroom.swf", symbol="collapseArrowUpSelected_Over"); + selectedUpIcon: Embed(source="darkroom.swf", symbol="collapseArrowUpSelected_Up"); +} + +.collapseLeft +{ + disabledSkin: Embed(source="darkroom.swf", symbol="clear"); + downSkin: Embed(source="darkroom.swf", symbol="clear"); + overSkin: Embed(source="darkroom.swf", symbol="clear"); + upSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="clear"); + disabledIcon: Embed(source="darkroom.swf", symbol="collapseArrowLeft_Up"); + downIcon: Embed(source="darkroom.swf", symbol="collapseArrowLeft_Over"); + overIcon: Embed(source="darkroom.swf", symbol="collapseArrowLeft_Over"); + upIcon: Embed(source="darkroom.swf", symbol="collapseArrowLeft_Up"); + selectedDisabledIcon: Embed(source="darkroom.swf", symbol="collapseArrowRightSelected_Up"); + selectedDownIcon: Embed(source="darkroom.swf", symbol="collapseArrowRightSelected_Over"); + selectedOverIcon: Embed(source="darkroom.swf", symbol="collapseArrowRightSelected_Over"); + selectedUpIcon: Embed(source="darkroom.swf", symbol="collapseArrowRightSelected_Up"); + paddingLeft:0; + paddingRight:0; +} + +.collapseRight +{ + disabledSkin: Embed(source="darkroom.swf", symbol="clear"); + downSkin: Embed(source="darkroom.swf", symbol="clear"); + overSkin: Embed(source="darkroom.swf", symbol="clear"); + upSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="clear"); + disabledIcon: Embed(source="darkroom.swf", symbol="collapseArrowRight_Up"); + downIcon: Embed(source="darkroom.swf", symbol="collapseArrowRight_Over"); + overIcon: Embed(source="darkroom.swf", symbol="collapseArrowRight_Over"); + upIcon: Embed(source="darkroom.swf", symbol="collapseArrowRight_Up"); + selectedDisabledIcon: Embed(source="darkroom.swf", symbol="collapseArrowLeftSelected_Up"); + selectedDownIcon: Embed(source="darkroom.swf", symbol="collapseArrowLeftSelected_Over"); + selectedOverIcon: Embed(source="darkroom.swf", symbol="collapseArrowLeftSelected_Over"); + selectedUpIcon: Embed(source="darkroom.swf", symbol="collapseArrowLeftSelected_Up"); + paddingLeft:0; + paddingRight:0; +} + +.plus +{ + disabledSkin: Embed(source="darkroom.swf", symbol="clear"); + downSkin: Embed(source="darkroom.swf", symbol="clear"); + overSkin: Embed(source="darkroom.swf", symbol="clear"); + upSkin: Embed(source="darkroom.swf", symbol="clear"); + disabledIcon: Embed(source="darkroom.swf", symbol="plusIcon_Up"); + downIcon: Embed(source="darkroom.swf", symbol="plusIcon_Over"); + overIcon: Embed(source="darkroom.swf", symbol="plusIcon_Over"); + upIcon: Embed(source="darkroom.swf", symbol="plusIcon_Up"); + paddingLeft:0; + paddingRight:0; +} + +.toggleSwitch +{ + disabledSkin: Embed(source="darkroom.swf", symbol="clear"); + downSkin: Embed(source="darkroom.swf", symbol="clear"); + overSkin: Embed(source="darkroom.swf", symbol="clear"); + upSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="clear"); + disabledIcon: Embed(source="darkroom.swf", symbol="toggleSwitch_Up"); + downIcon: Embed(source="darkroom.swf", symbol="toggleSwitch_Over"); + overIcon: Embed(source="darkroom.swf", symbol="toggleSwitch_Over"); + upIcon: Embed(source="darkroom.swf", symbol="toggleSwitch_Up"); + selectedDisabledIcon: Embed(source="darkroom.swf", symbol="toggleSwitchSelected_Up"); + selectedDownIcon: Embed(source="darkroom.swf", symbol="toggleSwitchSelected_Over"); + selectedOverIcon: Embed(source="darkroom.swf", symbol="toggleSwitchSelected_Over"); + selectedUpIcon: Embed(source="darkroom.swf", symbol="toggleSwitchSelected_Up"); + color: #999999; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + textDisabledColor: #1e1e1e; + fontWeight: "normal"; + textAlign:left; + /* Set labelPlacement:left on any buttons in MXML using this style to get the icon on the right*/ +} + +/* +//------------------------------ +// ButtonBar +//------------------------------ +*/ + +ButtonBar +{ + buttonStyleName: "buttonBarButton"; + firstButtonStyleName: "firstButtonBarButton"; + lastButtonStyleName: "lastButtonBarButton"; +} + +ToggleButtonBar +{ + buttonStyleName: "buttonBarButton"; + firstButtonStyleName: "firstButtonBarButton"; + lastButtonStyleName: "lastButtonBarButton"; +} + +.toolToggleBar +{ + buttonStyleName: "toolToggleButton"; + firstButtonStyleName: "toolToggleButton"; + lastButtonStyleName: "toolToggleButton"; + buttonWidth:28; + horizontalGap:0; + paddingLeft:0; + paddingRight:0; + selectedButtonTextStyleName:"selectedToolText"; +} + +.selectedToolText +{ + color: #ffffff; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + textDisabledColor: #1e1e1e; + fontWeight: "normal"; + +} + +/* +//------------------------------ +// ButtonBarButtons +//------------------------------ +*/ + +.firstButtonBarButton +{ + disabledSkin: Embed(source="darkroom.swf", symbol="ButtonBar_firstDisabledSkin"); + downSkin: Embed(source="darkroom.swf", symbol="ButtonBar_firstDownSkin"); + overSkin: Embed(source="darkroom.swf", symbol="ButtonBar_firstOverSkin"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="ButtonBar_firstSelectedDisabledSkin"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="ButtonBar_firstSelectedUpSkin"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="ButtonBar_firstSelectedUpSkin"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="ButtonBar_firstSelectedUpSkin"); + upSkin: Embed(source="darkroom.swf", symbol="ButtonBar_firstUpSkin"); + color: #aaaaaa; + textRollOverColor: #ffffff; + textSelectedColor: #ffffff; + disabledColor:#444444; +} +.buttonBarButton +{ + disabledSkin: Embed(source="darkroom.swf", symbol="ButtonBar_buttonDisabledSkin"); + downSkin: Embed(source="darkroom.swf", symbol="ButtonBar_buttonDownSkin"); + overSkin: Embed(source="darkroom.swf", symbol="ButtonBar_buttonOverSkin"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="ButtonBar_buttonSelectedDisabledSkin"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="ButtonBar_buttonSelectedUpSkin"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="ButtonBar_buttonSelectedUpSkin"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="ButtonBar_buttonSelectedUpSkin"); + upSkin: Embed(source="darkroom.swf", symbol="ButtonBar_buttonUpSkin"); + color: #aaaaaa; + textRollOverColor: #ffffff; + textSelectedColor: #ffffff; + disabledColor:#444444; +} + +.lastButtonBarButton +{ + disabledSkin: Embed(source="darkroom.swf", symbol="ButtonBar_lastDisabledSkin"); + downSkin: Embed(source="darkroom.swf", symbol="ButtonBar_lastDownSkin"); + overSkin: Embed(source="darkroom.swf", symbol="ButtonBar_lastOverSkin"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="ButtonBar_lastSelectedDisabledSkin"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="ButtonBar_lastSelectedUpSkin"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="ButtonBar_lastSelectedUpSkin"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="ButtonBar_lastSelectedUpSkin"); + upSkin: Embed(source="darkroom.swf", symbol="ButtonBar_lastUpSkin"); + color: #aaaaaa; + textRollOverColor: #ffffff; + textSelectedColor: #ffffff; + disabledColor:#444444; +} + +.toolToggleButton +{ + disabledSkin: Embed(source="darkroom.swf", symbol="clear"); + downSkin: Embed(source="darkroom.swf", symbol="clear"); + overSkin: Embed(source="darkroom.swf", symbol="clear"); + upSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="clear"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="clear"); + color: #808080; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + textDisabledColor: #1e1e1e; + fontWeight: "normal"; + paddingLeft:0; + paddingRight:0; +} + +/* +//------------------------------ +// CheckBox +//------------------------------ +*/ +CheckBox +{ + disabledIcon: Embed(source="darkroom.swf", symbol="CheckBox_disabledIcon"); + downIcon: Embed(source="darkroom.swf", symbol="CheckBox_downIcon"); + overIcon: Embed(source="darkroom.swf", symbol="CheckBox_overIcon"); + selectedDisabledIcon: Embed(source="darkroom.swf", symbol="CheckBox_selectedDisabledIcon"); + selectedDownIcon: Embed(source="darkroom.swf", symbol="CheckBox_selectedDownIcon"); + selectedOverIcon: Embed(source="darkroom.swf", symbol="CheckBox_selectedOverIcon"); + selectedUpIcon: Embed(source="darkroom.swf", symbol="CheckBox_selectedUpIcon"); + upIcon: Embed(source="darkroom.swf", symbol="CheckBox_upIcon"); + color: #cccccc; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + textDisabledColor: #1e1e1e; + fontSize:11; + fontWeight:normal; + fontFamily: "Myriad Pro"; + horizontalGap:0; +} + +/* +//------------------------------ +// ColorPicker +//------------------------------ +*/ +ColorPicker +{ + disabledSkin: Embed(source="darkroom.swf", symbol="ColorPicker_disabledSkin"); + downSkin: Embed(source="darkroom.swf", symbol="ColorPicker_downSkin"); + overSkin: Embed(source="darkroom.swf", symbol="ColorPicker_overSkin"); + upSkin: Embed(source="darkroom.swf", symbol="ColorPicker_upSkin"); + editableDisabledSkin: Embed(source="darkroom.swf", symbol="ColorPicker_disabledSkin"); + editableDownSkin: Embed(source="darkroom.swf", symbol="ColorPicker_downSkin"); + editableOverSkin: Embed(source="darkroom.swf", symbol="ColorPicker_overSkin"); + editableUpSkin: Embed(source="darkroom.swf", symbol="ColorPicker_upSkin"); +} + +/* +//------------------------------ +// ComboBox +//------------------------------ +*/ +ComboBox +{ + + disabledSkin: Embed(source="darkroom.swf", symbol="ComboBoxArrow_disabledSkin"); + downSkin: Embed(source="darkroom.swf", symbol="ComboBoxArrow_downSkin"); + editableDisabledSkin: Embed(source="darkroom.swf", symbol="ComboBoxArrow_editableDisabledSkin"); + editableDownSkin: Embed(source="darkroom.swf", symbol="ComboBoxArrow_editableDownSkin"); + editableOverSkin: Embed(source="darkroom.swf", symbol="ComboBoxArrow_editableOverSkin"); + editableUpSkin: Embed(source="darkroom.swf", symbol="ComboBoxArrow_editableUpSkin"); + overSkin: Embed(source="darkroom.swf", symbol="ComboBoxArrow_overSkin"); + upSkin: Embed(source="darkroom.swf", symbol="ComboBoxArrow_upSkin"); + color: #cccccc; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + textDisabledColor: #1e1e1e; + dropDownStyleName: "dropDown"; + fontSize:11; + fontWeight:normal; + fontFamily: "Myriad Pro"; + arrowButtonWidth:12; + paddingRight:0; + paddingLeft:0; +} + +/* +//------------------------------ +// Horizontal Divided Box +//------------------------------ +*/ +HDividedBox { + dividerSkin: Embed(source="darkroom.swf",symbol="clear"); +} + +/* +//------------------------------ +// DropDownMenus +//------------------------------ +*/ +.dropDown { + branchIcon: Embed(source="darkroom.swf",symbol="Menu_branchIcon"); + branchDisabledIcon: Embed(source="darkroom.swf",symbol="Menu_branchDisabledIcon"); + checkIcon: Embed(source="darkroom.swf",symbol="Menu_checkIcon"); + checkDisabledIcon: Embed(source="darkroom.swf",symbol="Menu_checkDisabledIcon"); + radioIcon: Embed(source="darkroom.swf",symbol="Menu_radioIcon"); + radioDisabledIcon: Embed(source="darkroom.swf",symbol="Menu_radioDisabledIcon"); + separatorSkin: Embed(source="darkroom.swf",symbol="Menu_separatorSkin"); + backgroundColor: #ffffff; + backgroundAlpha: .9; + borderStyle: solid; + borderThickness: 1; + borderColor: #1e1e1e; + cornerRadius:0; + color: #1e1e1e; + textRollOverColor: #ffffff; + textSelectedColor:#1e1e1e; + rollOverColor: #333333; +} + +/* +//------------------------------ +// CursorManager +//------------------------------ +*/ +CursorManager +{ + busyCursor: Embed(source="darkroom.swf", symbol="BusyCursor"); + busyCursorBackground: Embed(source="darkroom.swf",symbol="BusyCursor"); +} + +/* +//------------------------------ +// DataGrid +//------------------------------ +*/ +DataGrid +{ + + columnDropIndicatorSkin: Embed(source="darkroom.swf", symbol="DataGrid_columnDropIndicatorSkin"); + columnResizeSkin: Embed(source="darkroom.swf", symbol="DataGrid_columnResizeSkin"); + headerSeparatorSkin: Embed(source="darkroom.swf", symbol="DataGrid_headerSeparatorSkin"); + sortArrowSkin: Embed(source="darkroom.swf", symbol="DataGrid_sortArrowSkin"); + stretchCursor: Embed(source="darkroom.swf",symbol="DataGrid_stretchCursor"); + headerStyleName: "dataGridHeader"; + headerColors: #222222, #222222; + color:#aaaaaa; + rollOverColor: #333333; + selectionColor: #333333; + disabledColor: #1e1e1e; + textRollOverColor:#ffffff; + textSelectedColor:#ffffff; + selectiondDisabledColor: #1e1e1e; + verticalGridLines: false; + alternatingItemColors: #3e3e3e, #3e3e3e; + /*backgroundImage: Embed(source="darkroom.swf",symbol="lightGrey_Bg"); + backgroundSize:"100%";*/ + backgroundColor: #3e3e3e; + borderStyle: solid; + borderColor:#000000; + borderThickness:1; +} + +/* +//------------------------------ +// DataGridHeader +//------------------------------ +*/ +.dataGridHeader +{ + color: #aaaaaa; + textRollOverColor:#ffffff; + textSelectedColor:#ffffff; +} + +/* +//------------------------------ +// DateChooser +//------------------------------ +*/ +DateChooser +{ + headerColors: #222222, #222222; + cornerRadius:0; + borderColor:#000000; + backgroundColor:#3e3e3e; + color:#aaaaaa; + textRollOverColor:#ffffff; + textSelectedColor: #ffffff; + selectionColor:#222222; + + nextMonthDisabledSkin: Embed(source="darkroom.swf", symbol="DateChooser_nextMonthDisabledSkin"); + nextMonthDownSkin: Embed(source="darkroom.swf", symbol="DateChooser_nextMonthDownSkin"); + nextMonthOverSkin: Embed(source="darkroom.swf", symbol="DateChooser_nextMonthOverSkin"); + nextMonthUpSkin: Embed(source="darkroom.swf", symbol="DateChooser_nextMonthUpSkin"); + prevMonthDisabledSkin: Embed(source="darkroom.swf", symbol="DateChooser_prevMonthDisabledSkin"); + prevMonthDownSkin: Embed(source="darkroom.swf", symbol="DateChooser_prevMonthDownSkin"); + prevMonthOverSkin: Embed(source="darkroom.swf", symbol="DateChooser_prevMonthOverSkin"); + prevMonthUpSkin: Embed(source="darkroom.swf", symbol="DateChooser_prevMonthUpSkin"); + + nextYearDisabledSkin: Embed(source="darkroom.swf", symbol="DateChooser_nextYearDisabledSkin"); + nextYearDownSkin: Embed(source="darkroom.swf", symbol="DateChooser_nextYearDownSkin"); + nextYearOverSkin: Embed(source="darkroom.swf", symbol="DateChooser_nextYearOverSkin"); + nextYearUpSkin: Embed(source="darkroom.swf", symbol="DateChooser_nextYearUpSkin"); + prevYearDisabledSkin: Embed(source="darkroom.swf", symbol="DateChooser_prevYearDisabledSkin"); + prevYearDownSkin: Embed(source="darkroom.swf", symbol="DateChooser_prevYearDownSkin"); + prevYearOverSkin: Embed(source="darkroom.swf", symbol="DateChooser_prevYearOverSkin"); + prevYearUpSkin: Embed(source="darkroom.swf", symbol="DateChooser_prevYearUpSkin"); + + todayStyleName: "today"; + + todayIndicatorSkin: Embed(source="darkroom.swf", symbol="DateChooser_todayIndicatorSkin"); + rollOverIndicatorSkin: Embed(source="darkroom.swf", symbol="DateChooser_rollOverIndicatorSkin"); + selectionIndicatorSkin: Embed(source="darkroom.swf", symbol="DateChooser_selectionIndicatorSkin"); + + headerStyleName: "calendarHeader"; + weekDayStyleName: "weekDay"; + +} + +.today { + color: #ffffff; + textRollOverColor: #aaaaaa; + textSelectedColor: #aaaaaa; + diabledColor:#2c2c2c; +} + +.calendarHeader, .weekDay { + color: #ffffff; + horizontalGap:4; + fontWeight:normal; +} + +/* +//------------------------------ +// DateField +//------------------------------ +*/ +DateField +{ + disabledSkin: Embed(source="darkroom.swf",symbol="DateField_disabledSkin"); + downSkin: Embed(source="darkroom.swf",symbol="DateField_downSkin"); + overSkin: Embed(source="darkroom.swf",symbol="DateField_overSkin"); + upSkin: Embed(source="darkroom.swf",symbol="DateField_upSkin"); + cornerRadius:0; + borderThickness:1; + borderStyle:inset; + borderColor:#000000; + fontFamily: "Myriad Pro"; + fontWeight: normal; + fontSize:11; + backgroundColor:#666666; + color:#eeeeee; + textRollOverColor:#ffffff; +} + +/* +//------------------------------ +// DividedBox +//------------------------------ +*/ +DividedBox +{ + dividerSkin: Embed(source="darkroom.swf",symbol="DividedBox_dividerSkin"); + horizontalCursor: Embed(source="darkroom.swf",symbol="DividedBox_horizontalCursor"); + verticalCursor: Embed(source="darkroom.swf",symbol="DividedBox_verticalCursor"); +} + +/* +//------------------------------ +// DragManager +//------------------------------ +*/ +DragManager +{ + copyCursor: Embed(source="darkroom.swf",symbol="DragManager_copyCursor"); + + defaultDragImageSkin: Embed(source="darkroom.swf", symbol="DragManager_defaultDragImageSkin"); + + linkCursor: Embed(source="darkroom.swf",symbol="DragManager_linkCursor"); + moveCursor: Embed(source="darkroom.swf",symbol="DragManager_moveCursor"); + rejectCursor: Embed(source="darkroom.swf",symbol="DragManager_rejectCursor"); +} + +/* +//------------------------------ +// FormItem +//------------------------------ +*/ +FormItem +{ + indicatorSkin: Embed(source="darkroom.swf",symbol="FormItem_indicatorSkin"); +} + +/* +//------------------------------ +// Image +//------------------------------ +*/ +Image +{ + + brokenImageSkin: Embed(source="darkroom.swf",symbol="Loader_brokenImageSkin"); + +} + +/* +//------------------------------ +// Label +//------------------------------ +*/ +Label +{ + color:#ffffff +} + +/* +//------------------------------ +// LinkButton +//------------------------------ +*/ +LinkButton +{ + disabledSkin: Embed(source="darkroom.swf", symbol="clear"); + downSkin: Embed(source="darkroom.swf", symbol="clear"); + overSkin: Embed(source="darkroom.swf", symbol="clear"); + upSkin: Embed(source="darkroom.swf", symbol="clear"); + color: #808080; + selectionColor:#aaaaaa; + disabledColor:#ffffff; + textRollOverColor: #aaaaaa; + textSelectedColor:#aaaaaa; + textDisabledColor: #1e1e1e; + fontWeight: "normal"; + separatorColor: #808080; +} + +.sectionLinks +{ + fontSize: 18; +} + +/* +//------------------------------ +// Loader +//------------------------------ +*/ +Loader +{ + brokenImageSkin: Embed(source="darkroom.swf",symbol="Loader_brokenImageSkin"); + +} + +/* +//------------------------------ +// Menu +//------------------------------ +*/ +Menu +{ + branchIcon: Embed(source="darkroom.swf",symbol="Menu_branchIcon"); + branchDisabledIcon: Embed(source="darkroom.swf",symbol="Menu_branchDisabledIcon"); + checkIcon: Embed(source="darkroom.swf",symbol="Menu_checkIcon"); + checkDisabledIcon: Embed(source="darkroom.swf",symbol="Menu_checkDisabledIcon"); + radioIcon: Embed(source="darkroom.swf",symbol="Menu_radioIcon"); + radioDisabledIcon: Embed(source="darkroom.swf",symbol="Menu_radioDisabledIcon"); + separatorSkin: Embed(source="darkroom.swf",symbol="Menu_separatorSkin"); + backgroundColor: #000000; + backgroundAlpha: .9; + borderStyle: solid; + borderThickness: 0; + borderColor: #cccccc; + roundedCorners:5; + color: #ffffff; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + rollOverColor: #cccccc; +} + +/* +//------------------------------ +// darkMenu +//------------------------------ +*/ +.darkMenu +{ + branchIcon: Embed(source="darkroom.swf",symbol="whiteBranchIcon"); + branchDisabledIcon: Embed(source="darkroom.swf",symbol="whiteBranchIcon_Disabled"); + checkIcon: Embed(source="darkroom.swf",symbol="whiteCheckIcon"); + checkDisabledIcon: Embed(source="darkroom.swf",symbol="whiteCheckIcon_Disabled"); + radioIcon: Embed(source="darkroom.swf",symbol="whiteRadioIcon"); + radioDisabledIcon: Embed(source="darkroom.swf",symbol="whiteRadioIcon_Disabled"); + separatorSkin: Embed(source="darkroom.swf",symbol="Menu_separatorSkin"); + backgroundColor: #284040; + backgroundAlpha: .9; + borderStyle: solid; + borderThickness: 0; + borderColor: #cccccc; + roundedCorners:0; + color: #ffffff; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + rollOverColor: #284040; +} + +/* +//------------------------------ +// MenuBar +//------------------------------ +*/ +MenuBar +{ + + backgroundSkin: Embed(source="darkroom.swf", symbol="MenuBar_backgroundSkin"); + itemUpSkin: Embed(source="darkroom.swf", symbol="MenuBar_itemUpSkin"); + itemOverSkin: Embed(source="darkroom.swf", symbol="MenuBar_itemOverSkin"); + itemDownSkin: Embed(source="darkroom.swf", symbol="MenuBar_itemDownSkin"); + color: #aaaaaa; + backgroundColor:#ffffff; + textSelectedColor:#ffffff; + textRollOverColor:#ffffff; + rollOverColor:#ffffff; + menuStyleName: "dropDown"; +} + +/* +//------------------------------ +// NumericStepper +//------------------------------ +*/ +NumericStepper +{ + + downArrowDisabledSkin: Embed(source="darkroom.swf", symbol="NumericStepperDownArrow_disabledSkin"); + downArrowDownSkin: Embed(source="darkroom.swf", symbol="NumericStepperDownArrow_downSkin"); + downArrowOverSkin: Embed(source="darkroom.swf", symbol="NumericStepperDownArrow_overSkin"); + downArrowUpSkin: Embed(source="darkroom.swf", symbol="NumericStepperDownArrow_upSkin"); + upArrowDisabledSkin: Embed(source="darkroom.swf", symbol="NumericStepperUpArrow_disabledSkin"); + upArrowDownSkin: Embed(source="darkroom.swf", symbol="NumericStepperUpArrow_downSkin"); + upArrowOverSkin: Embed(source="darkroom.swf", symbol="NumericStepperUpArrow_overSkin"); + upArrowUpSkin: Embed(source="darkroom.swf", symbol="NumericStepperUpArrow_upSkin"); + cornerRadius:0; + borderThickness:1; + borderStyle:inset; + borderColor:#000000; + fontFamily: "Myriad Pro"; + fontWeight: normal; + fontSize:11; + backgroundColor:#666666; + color:#eeeeee; + textRollOverColor:#ffffff; +} + +/* +//------------------------------ +// Panel +//------------------------------ +*/ +Panel +{ + + closeButtonDisabledSkin: Embed(source="darkroom.swf",symbol="Panel_closeButtonDisabledSkin"); + closeButtonDownSkin: Embed(source="darkroom.swf",symbol="Panel_closeButtonDownSkin"); + closeButtonOverSkin: Embed(source="darkroom.swf",symbol="Panel_closeButtonOverSkin"); + closeButtonUpSkin: Embed(source="darkroom.swf",symbol="Panel_closeButtonUpSkin"); + borderSkin: Embed(source="darkroom.swf", symbol="Panel_borderSkin"); + /*titleBackgroundSkin: Embed(source="empty.swf", symbol="Panel_titleBackgroundSkin");*/ + borderThicknessLeft: 10; + borderThicknessRight: 11; + borderThicknessTop: 0; + borderThicknessBottom: 3; + headerHeight: 30; + cornerRadius:0; + titleStyleName: "panelTitle"; +} + +.panelTitle { + paddingTop:6; + textAlign: left; + fontSize: 10; + color: #ffffff; + borderStyle: none; + borderThickness:0; + /*fontWeight: bold;*/ +} + +/* +//------------------------------ +// Panel ControlBar +//------------------------------ +*/ +ControlBar +{ + borderSkin: Embed(source="darkroom.swf", symbol="Panel_controlBarBackgroundSkin"); + themeColor:#000000; +} + +ApplicationControlBar +{ + borderSkin: Embed(source="darkroom.swf", symbol="app_controlBarBackgroundSkin"); +} + +/* +//------------------------------ +// PopUpButton +//------------------------------ +*/ +PopUpButton +{ + + disabledSkin: Embed(source="darkroom.swf", symbol="PopUpButton_disabledSkin"); + downSkin: Embed(source="darkroom.swf", symbol="PopUpButton_downLeftSkin"); + overSkin: Embed(source="darkroom.swf", symbol="PopUpButton_overLeftSkin"); + popUpDownSkin: Embed(source="darkroom.swf", symbol="PopUpButton_downRightSkin"); + popUpOverSkin: Embed(source="darkroom.swf", symbol="PopUpButton_overRightSkin"); + upSkin: Embed(source="darkroom.swf", symbol="PopUpButton_upSkin"); + color: #cccccc; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + textDisabledColor: #1e1e1e; + dropDownStyleName: "dropDown"; + fontSize:11; + fontWeight:normal; + fontFamily: "Myriad Pro"; + arrowButtonWidth:12; + paddingRight:0; + paddingLeft:0; +} + +/* +//------------------------------ +// PopUpMenuButton +//------------------------------ +*/ +PopUpMenuButton +{ + + disabledSkin: Embed(source="darkroom.swf", symbol="PopUpButton_disabledSkin"); + downSkin: Embed(source="darkroom.swf", symbol="PopUpButton_downLeftSkin"); + overSkin: Embed(source="darkroom.swf", symbol="PopUpButton_overLeftSkin"); + popUpDownSkin: Embed(source="darkroom.swf", symbol="PopUpButton_downRightSkin"); + popUpOverSkin: Embed(source="darkroom.swf", symbol="PopUpButton_overRightSkin"); + upSkin: Embed(source="darkroom.swf", symbol="PopUpButton_upSkin"); + color: #cccccc; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + textDisabledColor: #1e1e1e; + fontSize:11; + fontWeight:normal; + fontFamily: "Myriad Pro"; + arrowButtonWidth:12; + paddingRight:0; + paddingLeft:0; + +} + + +/* +//------------------------------ +// ProgressBar +//------------------------------ +*/ +ProgressBar +{ + + barSkin: Embed(source="darkroom.swf", symbol="ProgressBarSkin"); + indeterminateSkin: Embed(source="darkroom.swf", symbol="ProgressIndeterminateSkin"); + trackSkin: Embed(source="darkroom.swf", symbol="ProgressTrackSkin"); + +} + +/* +//------------------------------ +// RadioButton +//------------------------------ +*/ +RadioButton +{ + + disabledIcon: Embed(source="darkroom.swf", symbol="RadioButton_disabledIcon"); + downIcon: Embed(source="darkroom.swf", symbol="RadioButton_downIcon"); + overIcon: Embed(source="darkroom.swf", symbol="RadioButton_overIcon"); + selectedDisabledIcon: Embed(source="darkroom.swf", symbol="RadioButtonSelected_disabledIcon"); + selectedDownIcon: Embed(source="darkroom.swf", symbol="RadioButtonSelected_downIcon"); + selectedOverIcon: Embed(source="darkroom.swf", symbol="RadioButtonSelected_overIcon"); + selectedUpIcon: Embed(source="darkroom.swf", symbol="RadioButtonSelected_upIcon"); + upIcon: Embed(source="darkroom.swf", symbol="RadioButton_upIcon"); + color: #cccccc; + textRollOverColor: #ffffff; + textSelectedColor:#ffffff; + disabledColor: #1e1e1e; + dropDownStyleName: "dropDown"; + fontSize:11; + fontWeight:normal; + fontFamily: "Myriad Pro"; + horizontalGap:0; +} + +/* +//------------------------------ +// Rich Text Editor +//------------------------------ +*/ + +RichTextEditor +{ + borderSkin: Embed(source="darkroom.swf", symbol="darkGrey_Bg"); + textAreaStyleName: "textArea"; +} + +.textArea +{ + fontFamily:""; +} + +/* +//------------------------------ +// Rules +//------------------------------ +*/ + +HRule +{ + strokeColor:#000000; + strokeWidth:2; + shadowColor:#333333; +} + +VRule +{ + strokeColor:#000000; + strokeWidth:2; + shadowColor:#333333; +} + +/* +//------------------------------ +// ScrollBars +//------------------------------ +*/ +ScrollBar +{ + + downArrowDisabledSkin: Embed(source="darkroom.swf", symbol="ScrollArrowDown_disabledSkin"); + downArrowDownSkin: Embed(source="darkroom.swf", symbol="ScrollArrowDown_downSkin"); + downArrowOverSkin: Embed(source="darkroom.swf", symbol="ScrollArrowDown_overSkin"); + downArrowUpSkin: Embed(source="darkroom.swf", symbol="ScrollArrowDown_upSkin"); + thumbDownSkin: Embed(source="darkroom.swf", symbol="ScrollThumb_downSkin"); + thumbIcon: Embed(source="darkroom.swf", symbol="ScrollBar_thumbIcon"); + thumbOverSkin: Embed(source="darkroom.swf", symbol="ScrollThumb_overSkin"); + thumbUpSkin: Embed(source="darkroom.swf", symbol="ScrollThumb_upSkin"); + trackSkin: Embed(source="darkroom.swf", symbol="ScrollTrack_Skin"); + upArrowDisabledSkin: Embed(source="darkroom.swf", symbol="ScrollArrowUp_disabledSkin"); + upArrowDownSkin: Embed(source="darkroom.swf", symbol="ScrollArrowUp_downSkin"); + upArrowOverSkin: Embed(source="darkroom.swf", symbol="ScrollArrowUp_overSkin"); + upArrowUpSkin: Embed(source="darkroom.swf", symbol="ScrollArrowUp_upSkin"); + +} + +.trayScrollBar +{ + + downArrowDisabledSkin: Embed(source="darkroom.swf", symbol="clearPixel"); + downArrowDownSkin: Embed(source="darkroom.swf", symbol="clearPixel"); + downArrowOverSkin: Embed(source="darkroom.swf", symbol="clearPixel"); + downArrowUpSkin: Embed(source="darkroom.swf", symbol="clearPixel"); + thumbDownSkin: Embed(source="darkroom.swf", symbol="trayThumb_Over"); + thumbIcon: Embed(source="darkroom.swf", symbol="ScrollBar_thumbIcon"); + thumbOverSkin: Embed(source="darkroom.swf", symbol="trayThumb_Over"); + thumbUpSkin: Embed(source="darkroom.swf", symbol="trayThumb_Up"); + trackSkin: Embed(source="darkroom.swf", symbol="trayTrackSkin"); + upArrowDisabledSkin: Embed(source="darkroom.swf", symbol="clearPixel"); + upArrowDownSkin: Embed(source="darkroom.swf", symbol="clearPixel"); + upArrowOverSkin: Embed(source="darkroom.swf", symbol="clearPixel"); + upArrowUpSkin: Embed(source="darkroom.swf", symbol="clearPixel"); + +} + +/* +//------------------------------ +// Sliders +//------------------------------ +*/ + +HSlider, VSlider +{ + thumbDisabledSkin: Embed(source="darkroom.swf", symbol="SliderThumb_disabledSkin"); + thumbDownSkin: Embed(source="darkroom.swf", symbol="SliderThumb_downSkin"); + thumbOverSkin: Embed(source="darkroom.swf", symbol="SliderThumb_overSkin"); + thumbUpSkin: Embed(source="darkroom.swf", symbol="SliderThumb_upSkin"); + trackHighlightSkin: Embed(source="darkroom.swf", symbol="SliderHighlight_Skin"); + trackSkin: Embed(source="darkroom.swf", symbol="SliderTrack_Skin"); + tickColor:#262626; + tickWidth:3; + tickOffset:-1; + tickInterval:1; + tickThickness:1; +} + +/* +//------------------------------ +// Tab +//------------------------------ +*/ +TabBar +{ + firstButtonStyleName: "tabStyle"; + firstTabStyleName: "tabStyle"; + tabStyleName: "tabStyle"; + buttonStyleName: "tabStyle"; + lastButtonStyleName: "tabStyle"; + lastTabStyleName: "tabStyle"; + selectedTabTextStyleName: "selectedTabText"; + color: #aaaaaa; + textRollOverColor: #ffffff; + textSelectedColor:#444444; + disabledColor:#111111; +} + +.tabStyle { + disabledSkin: Embed(source="darkroom.swf", symbol="Tab_disabledSkin"); + downSkin: Embed(source="darkroom.swf", symbol="Tab_downSkin"); + overSkin: Embed(source="darkroom.swf", symbol="Tab_overSkin"); + selectedDisabledSkin: Embed(source="darkroom.swf", symbol="TabSelected_disabledSkin"); + selectedDownSkin: Embed(source="darkroom.swf", symbol="TabSelected_upSkin"); + selectedOverSkin: Embed(source="darkroom.swf", symbol="TabSelected_upSkin"); + selectedUpSkin: Embed(source="darkroom.swf", symbol="TabSelected_upSkin"); + upSkin: Embed(source="darkroom.swf", symbol="Tab_upSkin"); + color:#aaaaaa; + textRollOverColor:#ffffff; + textSelectedColor:#ffffff; +} + +.selectedTabText { + color: #ffffff; + textRollOverColor: #ffffff; + textSelectedColor:#aaaaaa; + disabledColor:#111111; +} + +/* +//------------------------------ +// Tab Navigator +//------------------------------ +*/ +TabNavigator +{ + borderStyle:solid; + borderColor:#000000; + borderThickness:1; + backgroundColor:#3e3e3e; + fontWeight:normal; + fontSize:11; + borderSkin: Embed(source="darkroom.swf", symbol="tabNav_bg"); + color: #aaaaaa; + textRollOverColor: #ffffff; + textSelectedColor:#444444; + disabledColor:#111111; +} + +/* +//------------------------------ +// Text Styling +//------------------------------ +*/ +.appTitle +{ + fontFamily: "Myriad Pro"; + fontWight: "normal"; + fontSize:20; + color:#999999; + +} + +/* +//------------------------------ +// TextInput +//------------------------------ +*/ +TextInput +{ + color:#000000; + fontFamily:"Myriad Pro"; +} + +/* +//------------------------------ +// TextArea +//------------------------------ +*/ +TextArea +{ + color: #000000; + fontFamily:"Myriad Pro"; +} + +/* +//------------------------------ +// ToolTip +//------------------------------ +*/ +ToolTip +{ + + borderSkin: Embed(source="darkroom.swf", symbol="ToolTip_borderSkin"); + color:#333333; +} + +/* +//------------------------------ +// Tree +//------------------------------ +*/ +Tree +{ + defaultLeafIcon: Embed(source="darkroom.swf",symbol="Tree_defaultLeafIcon"); + disclosureClosedIcon: Embed(source="darkroom.swf",symbol="Tree_disclosureClosedIcon"); + disclosureOpenIcon: Embed(source="darkroom.swf",symbol="Tree_disclosureOpenIcon"); + folderClosedIcon: Embed(source="darkroom.swf",symbol="Tree_folderClosedIcon"); + folderOpenIcon: Embed(source="darkroom.swf",symbol="Tree_folderOpenIcon"); + /*borderSkin: Embed(source="darkroom.swf",symbol="lightGrey_Bg");*/ + backgroundAlpha:0; + paddingTop:6; + paddingLeft:6; + borderThickness:0; + color:#aaaaaa; + rollOverColor: #333333; + selectionColor: #333333; + disabledColor: #1e1e1e; + textRollOverColor:#ffffff; + textSelectedColor:#ffffff; + selectiondDisabledColor: #1e1e1e; +} + +/* +//------------------------------ +// TitleWindow +//------------------------------ +*/ +TitleWindow +{ + closeButtonDisabledSkin: Embed(source="darkroom.swf",symbol="Panel_closeButtonDisabledSkin"); + closeButtonDownSkin: Embed(source="darkroom.swf",symbol="Panel_closeButtonDownSkin"); + closeButtonOverSkin: Embed(source="darkroom.swf",symbol="Panel_closeButtonOverSkin"); + closeButtonUpSkin: Embed(source="darkroom.swf",symbol="Panel_closeButtonUpSkin"); + titleStyleName: "windowTitle"; + cornerRadius:0; + borderStyle: none; + borderThickness:0; + headerHeight:36; + controlBarStyleName: "windowControlBar"; + borderThicknessRight:0; + borderThicknessLeft:0; + borderThicknessBottom:0; +} + +.windowTitle { + textAlign: left; + fontSize: 10; + verticalAlign:middle; + color: #ffffff; + /*fontWeight: bold;*/ +} + +.windowControlBar { + backgroundImage: Embed(source="darkroom.swf",symbol="Panel_controlBarBackgroundSkin"); + backgroundSize:"100%"; +} + +/* +//------------------------------ +// View Stack +//------------------------------ +*/ +ViewStack +{ + /*borderStyle:solid; + borderColor:#000000; + borderThickness:1; + backgroundColor:#3e3e3e; + fontWeight:normal; + fontSize:11; + borderSkin: Embed(source="darkroom.swf",symbol="lightGrey_Bg");*/ +} + + diff --git a/tests/style/darkroom.swf b/tests/style/darkroom.swf new file mode 100755 index 0000000..2f34ca4 Binary files /dev/null and b/tests/style/darkroom.swf differ diff --git a/tests/style/myriad.swf b/tests/style/myriad.swf new file mode 100755 index 0000000..4e2210a Binary files /dev/null and b/tests/style/myriad.swf differ