├── .gitignore ├── README.md ├── build.properties ├── build.xml └── src ├── com ├── adobe │ ├── crypto │ │ ├── HMAC.as │ │ ├── MD5.as │ │ ├── MD5Stream.as │ │ ├── SHA1.as │ │ ├── SHA224.as │ │ ├── SHA256.as │ │ └── WSSEUsernameToken.as │ └── utils │ │ ├── ArrayUtil.as │ │ ├── DateUtil.as │ │ ├── DictionaryUtil.as │ │ ├── IntUtil.as │ │ ├── NumberFormatter.as │ │ ├── StringUtil.as │ │ └── XMLUtil.as ├── bit101 │ ├── charts │ │ ├── BarChart.as │ │ ├── Chart.as │ │ ├── LineChart.as │ │ └── PieChart.as │ ├── components │ │ ├── Accordion.as │ │ ├── Calendar.as │ │ ├── CheckBox.as │ │ ├── ColorChooser.as │ │ ├── ComboBox.as │ │ ├── Component.as │ │ ├── FPSMeter.as │ │ ├── HBox.as │ │ ├── HRangeSlider.as │ │ ├── HScrollBar.as │ │ ├── HSlider.as │ │ ├── HUISlider.as │ │ ├── IndicatorLight.as │ │ ├── InputText.as │ │ ├── Knob.as │ │ ├── Label.as │ │ ├── List.as │ │ ├── ListItem.as │ │ ├── Meter.as │ │ ├── NumericStepper.as │ │ ├── Panel.as │ │ ├── ProgressBar.as │ │ ├── PushButton.as │ │ ├── RadioButton.as │ │ ├── RangeSlider.as │ │ ├── RotarySelector.as │ │ ├── ScrollBar.as │ │ ├── ScrollPane.as │ │ ├── Slider.as │ │ ├── Style.as │ │ ├── Text.as │ │ ├── TextArea.as │ │ ├── UISlider.as │ │ ├── VBox.as │ │ ├── VRangeSlider.as │ │ ├── VScrollBar.as │ │ ├── VSlider.as │ │ ├── VUISlider.as │ │ ├── WheelMenu.as │ │ └── Window.as │ └── utils │ │ └── MinimalConfigurator.as ├── gskinner │ └── geom │ │ └── ColorMatrix.as ├── hurlant │ ├── crypto │ │ ├── Crypto.as │ │ ├── cert │ │ │ ├── MozillaRootCertificates.as │ │ │ ├── X509Certificate.as │ │ │ └── X509CertificateCollection.as │ │ ├── hash │ │ │ ├── HMAC.as │ │ │ ├── IHMAC.as │ │ │ ├── IHash.as │ │ │ ├── MAC.as │ │ │ ├── MD2.as │ │ │ ├── MD5.as │ │ │ ├── SHA1.as │ │ │ ├── SHA224.as │ │ │ ├── SHA256.as │ │ │ └── SHABase.as │ │ ├── prng │ │ │ ├── ARC4.as │ │ │ ├── IPRNG.as │ │ │ ├── Random.as │ │ │ └── TLSPRF.as │ │ ├── rsa │ │ │ └── RSAKey.as │ │ ├── symmetric │ │ │ ├── AESKey.as │ │ │ ├── BlowFishKey.as │ │ │ ├── CBCMode.as │ │ │ ├── CFB8Mode.as │ │ │ ├── CFBMode.as │ │ │ ├── CTRMode.as │ │ │ ├── DESKey.as │ │ │ ├── ECBMode.as │ │ │ ├── ICipher.as │ │ │ ├── IMode.as │ │ │ ├── IPad.as │ │ │ ├── IStreamCipher.as │ │ │ ├── ISymmetricKey.as │ │ │ ├── IVMode.as │ │ │ ├── NullPad.as │ │ │ ├── OFBMode.as │ │ │ ├── PKCS5.as │ │ │ ├── SSLPad.as │ │ │ ├── SimpleIVMode.as │ │ │ ├── TLSPad.as │ │ │ ├── TripleDESKey.as │ │ │ └── XTeaKey.as │ │ ├── tests │ │ │ ├── AESKeyTest.as │ │ │ ├── ARC4Test.as │ │ │ ├── BigIntegerTest.as │ │ │ ├── BlowFishKeyTest.as │ │ │ ├── CBCModeTest.as │ │ │ ├── CFB8ModeTest.as │ │ │ ├── CFBModeTest.as │ │ │ ├── CTRModeTest.as │ │ │ ├── DESKeyTest.as │ │ │ ├── ECBModeTest.as │ │ │ ├── HMACTest.as │ │ │ ├── ITestHarness.as │ │ │ ├── MD2Test.as │ │ │ ├── MD5Test.as │ │ │ ├── OFBModeTest.as │ │ │ ├── RSAKeyTest.as │ │ │ ├── SHA1Test.as │ │ │ ├── SHA224Test.as │ │ │ ├── SHA256Test.as │ │ │ ├── TLSPRFTest.as │ │ │ ├── TestCase.as │ │ │ ├── TripleDESKeyTest.as │ │ │ └── XTeaKeyTest.as │ │ └── tls │ │ │ ├── BulkCiphers.as │ │ │ ├── CipherSuites.as │ │ │ ├── IConnectionState.as │ │ │ ├── ISecurityParameters.as │ │ │ ├── KeyExchanges.as │ │ │ ├── MACs.as │ │ │ ├── SSLConnectionState.as │ │ │ ├── SSLEvent.as │ │ │ ├── SSLSecurityParameters.as │ │ │ ├── TLSConfig.as │ │ │ ├── TLSConnectionState.as │ │ │ ├── TLSEngine.as │ │ │ ├── TLSError.as │ │ │ ├── TLSEvent.as │ │ │ ├── TLSSecurityParameters.as │ │ │ ├── TLSSocket.as │ │ │ ├── TLSSocketEvent.as │ │ │ └── TLSTest.as │ ├── math │ │ ├── BarrettReduction.as │ │ ├── BigInteger.as │ │ ├── ClassicReduction.as │ │ ├── IReduction.as │ │ ├── MontgomeryReduction.as │ │ ├── NullReduction.as │ │ └── bi_internal.as │ └── util │ │ ├── ArrayUtil.as │ │ ├── Base64.as │ │ ├── Hex.as │ │ ├── Memory.as │ │ ├── asn1 │ │ ├── parser │ │ │ ├── any.as │ │ │ ├── bitString.as │ │ │ ├── bmpString.as │ │ │ ├── boolean.as │ │ │ ├── choice.as │ │ │ ├── defaultValue.as │ │ │ ├── explicitTag.as │ │ │ ├── extract.as │ │ │ ├── generalizedTime.as │ │ │ ├── ia5String.as │ │ │ ├── implicitTag.as │ │ │ ├── integer.as │ │ │ ├── nulll.as │ │ │ ├── octetString.as │ │ │ ├── oid.as │ │ │ ├── optional.as │ │ │ ├── printableString.as │ │ │ ├── sequence.as │ │ │ ├── sequenceOf.as │ │ │ ├── setOf.as │ │ │ ├── teletexString.as │ │ │ ├── universalString.as │ │ │ ├── utcTime.as │ │ │ └── utf8String.as │ │ └── type │ │ │ ├── ASN1Type.as │ │ │ ├── AnyType.as │ │ │ ├── BMPStringType.as │ │ │ ├── BitStringType.as │ │ │ ├── BooleanType.as │ │ │ ├── ChoiceType.as │ │ │ ├── GeneralizedTimeType.as │ │ │ ├── IA5StringType.as │ │ │ ├── IntegerType.as │ │ │ ├── NullType.as │ │ │ ├── OIDType.as │ │ │ ├── OctetStringType.as │ │ │ ├── PrintableStringType.as │ │ │ ├── SequenceType.as │ │ │ ├── SetType.as │ │ │ ├── StringType.as │ │ │ ├── TeletexStringType.as │ │ │ ├── UTCTimeType.as │ │ │ ├── UTF8StringType.as │ │ │ └── UniversalStringType.as │ │ └── der │ │ ├── ByteString.as │ │ ├── DER.as │ │ ├── IAsn1Type.as │ │ ├── Integer.as │ │ ├── OID.as │ │ ├── ObjectIdentifier.as │ │ ├── PEM.as │ │ ├── PrintableString.as │ │ ├── Sequence.as │ │ ├── Set.as │ │ ├── Type.as │ │ ├── Type2.as │ │ └── UTCTime.as └── soma │ └── ui │ ├── BaseUI.as │ ├── ElementUI.as │ ├── events │ └── EventUI.as │ ├── layouts │ ├── CanvasUI.as │ ├── HBoxUI.as │ ├── LayoutUI.as │ ├── TileUI.as │ └── VBoxUI.as │ └── vo │ ├── GapUI.as │ ├── PaddingUI.as │ └── PropertiesUI.as ├── gnu └── as3 │ └── gettext │ ├── AsGettext.as │ ├── Domain.as │ ├── FxGettext.as │ ├── GettextError.as │ ├── ISO_3166.as │ ├── ISO_639_1.as │ ├── Locale.as │ ├── MOFile.as │ ├── PACKAGE.as │ ├── _.as │ ├── _FxGettext.as │ ├── _Gettext.as │ ├── _Locale.as │ ├── dgettext.as │ ├── gettext.as │ ├── gettext_noop.as │ ├── parseMOBytes.as │ ├── services │ ├── IGettextService.as │ ├── LocalFilesystemService.as │ ├── URLLoaderService.as │ └── _.as │ └── sprintf.as ├── manifest.xml └── org └── zengrong ├── air └── utils │ ├── Updater.as │ └── getDesc.as ├── assets ├── Assets.as ├── AssetsEvent.as ├── AssetsProgressVO.as └── AssetsType.as ├── display ├── GestureHelper.as ├── LoaderScreen.as ├── MovableSprite.as ├── bmp │ ├── BMPDiverseSlicer.as │ ├── BMPMovableSprite.as │ ├── BMPMovieClip.as │ ├── BMPSlicer.as │ ├── BMPSprite.as │ └── BMPText.as ├── character │ ├── ActionLabel.as │ ├── Character.as │ ├── LabeledChar.as │ └── MovableChar.as └── spritesheet │ ├── ISpriteSheetMetadata.as │ ├── MaskType.as │ ├── SpriteSheet.as │ ├── SpriteSheetMetadata.as │ ├── SpriteSheetMetadataJSON.as │ ├── SpriteSheetMetadataStarling.as │ ├── SpriteSheetMetadataStringWraper.as │ ├── SpriteSheetMetadataTXT.as │ ├── SpriteSheetMetadataType.as │ ├── SpriteSheetMetadataWrapper.as │ ├── SpriteSheetMetadataXML.as │ └── SpriteSheetType.as ├── events ├── InfoEvent.as └── TouchAndGestureEvent.as ├── file ├── CSV.as └── FileEnding.as ├── flex ├── components │ ├── ColoredDataGrid.as │ ├── ImageButton.mxml │ ├── Loader.as │ ├── Scroller.as │ ├── SimpleScroller.as │ ├── SpriteSheetGroup.as │ └── VideoComponent.as ├── layouts │ ├── SpriteSheetBitmapFillMode.as │ ├── SpriteSheetCell.as │ ├── SpriteSheetCellVO.as │ ├── SpriteSheetGridLayout.as │ ├── SpriteSheetHLayout.as │ ├── SpriteSheetLayoutBase.as │ └── SpriteSheetVLayout.as ├── primitives │ └── SpriteSheetBitmapImage.as └── utils │ ├── Dialog.as │ └── JS.as ├── logging ├── Firebug.as ├── FirebugLogger.as ├── Logger.as └── targets │ ├── FirebugTarget.as │ └── LCDebugTarget.as ├── media ├── NetConnectionInfoCode.as ├── NetStreamInfoCode.as └── cm │ ├── CM.as │ ├── CMEvent.as │ └── CMVO.as ├── net ├── HTTPLoader.as ├── HTTPLoaderAsync.as ├── HTTPLoaderDoneVO.as ├── HTTPLoaderErrorVO.as ├── HTTPLoaderVO.as ├── ILoader.as ├── PacketBuffer.as ├── PacketString.as ├── SoundLoader.as ├── SpriteSheetLoader.as └── VisualLoader.as ├── rpc ├── FaultEvent.as ├── Operation.as ├── OperationPool.as ├── Remoting.as ├── ResultEvent.as └── ServiceProxy.as ├── text └── FTEFactory.as ├── ui ├── CDImageButton.as ├── ClassButton.as ├── Component.as ├── DisplayObjectButtonBase.as ├── ImageButton.as ├── Style.as ├── Tooltip.as ├── UI.as └── VideoDisplay.as └── utils ├── BitmapUtil.as ├── ByteArrayVariant.as ├── ByteSize.as ├── Chessboard.as ├── ColorMatrix.as ├── GC.as ├── ImageDecoder.as ├── JSDialogBox.as ├── MathUtil.as ├── OSType.as ├── ObjectUtil.as ├── SOUtil.as ├── Stats.as ├── StringUtil.as ├── TimeUtil.as ├── TimerUpdate.as ├── Vec2D.as ├── checkPlatform.as └── checkVersion.as /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | *.as3proj 3 | *.bat 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #[zengrong.net][]开发的AS3库# 2 | [zengrong.net]:http://www.zengrong.net 3 | -------------------------------------------------------------------------------- /build.properties: -------------------------------------------------------------------------------- 1 | PROJECT_NAME=zrongas3 2 | 3 | # The project can have multiple main class file. 4 | MAIN_NAME=zrongas3 5 | 6 | FLEX_HOME=D:/flashsdks/flex4.6.0 7 | FLEX_FRAMEWORKS=${FLEX_HOME}/frameworks 8 | 9 | # SRC - mxml and as files 10 | # BIN - output files 11 | # LIB - swc files 12 | SRC_DIR=${basedir}/src 13 | BIN_DIR=${basedir}/bin 14 | LIB_DIR=${basedir}/lib 15 | 16 | # Your application ID (must match of Application descriptor) 17 | APP_ID=zrongas3 18 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | swf.file:${swf.file} 13 | swf.name:${swf.name} 14 | FLEX_HOME:${FLEX_HOME} 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | Base dir:${basedir} 37 | Building swf file ${swf.file}... 38 | debug:${var.debug} optimize:${var.optimize} swfversion:${var.swfversion} 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/com/adobe/utils/NumberFormatter.as: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2008, Adobe Systems Incorporated 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | * Neither the name of Adobe Systems Incorporated nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 21 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | package com.adobe.utils 34 | { 35 | 36 | /** 37 | * Class that contains static utility methods for formatting Numbers 38 | * 39 | * @langversion ActionScript 3.0 40 | * @playerversion Flash 9.0 41 | * @tiptext 42 | * 43 | * @see #mx.formatters.NumberFormatter 44 | */ 45 | public class NumberFormatter 46 | { 47 | 48 | /** 49 | * Formats a number to include a leading zero if it is a single digit 50 | * between -1 and 10. 51 | * 52 | * @param n The number that will be formatted 53 | * 54 | * @return A string with single digits between -1 and 10 padded with a 55 | * leading zero. 56 | * 57 | * @langversion ActionScript 3.0 58 | * @playerversion Flash 9.0 59 | * @tiptext 60 | */ 61 | public static function addLeadingZero(n:Number):String 62 | { 63 | var out:String = String(n); 64 | 65 | if(n < 10 && n > -1) 66 | { 67 | out = "0" + out; 68 | } 69 | 70 | return out; 71 | } 72 | 73 | } 74 | } -------------------------------------------------------------------------------- /src/com/bit101/components/HRangeSlider.as: -------------------------------------------------------------------------------- 1 | /** 2 | * HRangeSlider.as 3 | * Keith Peters 4 | * version 0.9.10 5 | * 6 | * A horizontal slider with two handles for selecting a range of values. 7 | * 8 | * Copyright (c) 2011 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | 33 | public class HRangeSlider extends RangeSlider 34 | { 35 | public function HRangeSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null) 36 | { 37 | super(HORIZONTAL, parent, xpos, ypos, defaultHandler); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/com/bit101/components/HScrollBar.as: -------------------------------------------------------------------------------- 1 | /** 2 | * HScrollBar.as 3 | * Keith Peters 4 | * version 0.9.10 5 | * 6 | * A horizontal scroll bar for use in other components. 7 | * 8 | * Copyright (c) 2011 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | 33 | /** 34 | * Constructor 35 | * @param parent The parent DisplayObjectContainer on which to add this ScrollBar. 36 | * @param xpos The x position to place this component. 37 | * @param ypos The y position to place this component. 38 | * @param defaultHandler The event handling function to handle the default event for this component (change in this case). 39 | */ 40 | public class HScrollBar extends ScrollBar 41 | { 42 | public function HScrollBar(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function=null) 43 | { 44 | super(Slider.HORIZONTAL, parent, xpos, ypos, defaultHandler); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/com/bit101/components/HSlider.as: -------------------------------------------------------------------------------- 1 | /** 2 | * HSlider.as 3 | * Keith Peters 4 | * version 0.9.10 5 | * 6 | * A Horizontal Slider component for choosing values. 7 | * 8 | * Copyright (c) 2011 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | 33 | public class HSlider extends Slider 34 | { 35 | /** 36 | * Constructor 37 | * @param parent The parent DisplayObjectContainer on which to add this HSlider. 38 | * @param xpos The x position to place this component. 39 | * @param ypos The y position to place this component. 40 | * @param defaultHandler The event handling function to handle the default event for this component. 41 | */ 42 | public function HSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null) 43 | { 44 | super(Slider.HORIZONTAL, parent, xpos, ypos, defaultHandler); 45 | } 46 | 47 | } 48 | } -------------------------------------------------------------------------------- /src/com/bit101/components/VRangeSlider.as: -------------------------------------------------------------------------------- 1 | /** 2 | * VRangeSlider.as 3 | * Keith Peters 4 | * version 0.9.10 5 | * 6 | * A vertical slider with two handles for selecting a range of values. 7 | * 8 | * Copyright (c) 2011 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | 33 | public class VRangeSlider extends RangeSlider 34 | { 35 | public function VRangeSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null) 36 | { 37 | super(VERTICAL, parent, xpos, ypos, defaultHandler); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/com/bit101/components/VScrollBar.as: -------------------------------------------------------------------------------- 1 | /** 2 | * VScrollBar.as 3 | * Keith Peters 4 | * version 0.9.10 5 | * 6 | * A vertical scroll bar for use in other components. 7 | * 8 | * Copyright (c) 2011 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | 33 | public class VScrollBar extends ScrollBar 34 | { 35 | /** 36 | * Constructor 37 | * @param parent The parent DisplayObjectContainer on which to add this ScrollBar. 38 | * @param xpos The x position to place this component. 39 | * @param ypos The y position to place this component. 40 | * @param defaultHandler The event handling function to handle the default event for this component (change in this case). 41 | */ 42 | public function VScrollBar(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function=null) 43 | { 44 | super(Slider.VERTICAL, parent, xpos, ypos, defaultHandler); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/com/bit101/components/VSlider.as: -------------------------------------------------------------------------------- 1 | /** 2 | * VSlider.as 3 | * Keith Peters 4 | * version 0.9.10 5 | * 6 | * A Vertical Slider component for choosing values. 7 | * 8 | * Copyright (c) 2011 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | 33 | public class VSlider extends Slider 34 | { 35 | /** 36 | * Constructor 37 | * @param parent The parent DisplayObjectContainer on which to add this Slider. 38 | * @param xpos The x position to place this component. 39 | * @param ypos The y position to place this component. 40 | * @param defaultHandler The event handling function to handle the default event for this component. 41 | */ 42 | public function VSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null) 43 | { 44 | super(Slider.VERTICAL, parent, xpos, ypos, defaultHandler); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/com/hurlant/crypto/cert/X509CertificateCollection.as: -------------------------------------------------------------------------------- 1 | /** 2 | * X509CertificateCollection 3 | * 4 | * A class to store and index X509 Certificates by Subject. 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.crypto.cert { 10 | 11 | public class X509CertificateCollection { 12 | 13 | private var _map:Object; 14 | 15 | public function X509CertificateCollection() { 16 | _map = {}; 17 | } 18 | 19 | /** 20 | * Mostly meant for built-in CA loading. 21 | * This entry-point allows to index CAs without parsing them. 22 | * 23 | * @param name A friendly name. not currently used 24 | * @param subject base64 DER encoded Subject principal for the Cert 25 | * @param pem PEM encoded certificate data 26 | * 27 | */ 28 | public function addPEMCertificate(name:String, subject:String, pem:String):void { 29 | _map[subject] = new X509Certificate(pem); 30 | } 31 | 32 | /** 33 | * Adds a X509 certificate to the collection. 34 | * This call will force the certificate to be parsed. 35 | * 36 | * @param cert A X509 certificate 37 | * 38 | */ 39 | public function addCertificate(cert:X509Certificate):void { 40 | var subject:String = cert.getSubjectPrincipal(); 41 | _map[subject] = cert; 42 | } 43 | 44 | /** 45 | * Returns a X509 Certificate present in the collection, given 46 | * a base64 DER encoded X500 Subject principal 47 | * 48 | * @param subject A Base64 DER-encoded Subject principal 49 | * @return A matching certificate, or null. 50 | * 51 | */ 52 | public function getCertificate(subject:String):X509Certificate { 53 | return _map[subject]; 54 | } 55 | 56 | } 57 | } -------------------------------------------------------------------------------- /src/com/hurlant/crypto/hash/HMAC.as: -------------------------------------------------------------------------------- 1 | /** 2 | * HMAC 3 | * 4 | * An ActionScript 3 implementation of HMAC, Keyed-Hashing for Message 5 | * Authentication, as defined by RFC-2104 6 | * Copyright (c) 2007 Henri Torgemane 7 | * 8 | * See LICENSE.txt for full license information. 9 | */ 10 | package com.hurlant.crypto.hash 11 | { 12 | import flash.utils.ByteArray; 13 | import com.hurlant.util.Hex; 14 | 15 | public class HMAC implements IHMAC 16 | { 17 | private var hash:IHash; 18 | private var bits:uint; 19 | 20 | /** 21 | * Create a HMAC object, using a Hash function, and 22 | * optionally a number of bits to return. 23 | * The HMAC will be truncated to that size if needed. 24 | */ 25 | public function HMAC(hash:IHash, bits:uint=0) { 26 | this.hash = hash; 27 | this.bits = bits; 28 | } 29 | 30 | 31 | public function getHashSize():uint { 32 | if (bits!=0) { 33 | return bits/8; 34 | } else { 35 | return hash.getHashSize(); 36 | } 37 | } 38 | 39 | /** 40 | * Compute a HMAC using a key and some data. 41 | * It doesn't modify either, and returns a new ByteArray with the HMAC value. 42 | */ 43 | public function compute(key:ByteArray, data:ByteArray):ByteArray { 44 | var hashKey:ByteArray; 45 | if (key.length>hash.getInputSize()) { 46 | hashKey = hash.hash(key); 47 | } else { 48 | hashKey = new ByteArray; 49 | hashKey.writeBytes(key); 50 | } 51 | while (hashKey.length0 && bits<8*outerHash.length) { 69 | outerHash.length = bits/8; 70 | } 71 | return outerHash; 72 | } 73 | public function dispose():void { 74 | hash = null; 75 | bits = 0; 76 | } 77 | public function toString():String { 78 | return "hmac-"+(bits>0?bits+"-":"")+hash.toString(); 79 | } 80 | 81 | } 82 | } -------------------------------------------------------------------------------- /src/com/hurlant/crypto/hash/IHMAC.as: -------------------------------------------------------------------------------- 1 | /** 2 | * HMAC 3 | * 4 | * An ActionScript 3 interface for HMAC & MAC 5 | * implementations. 6 | * 7 | * Loosely copyrighted by Bobby Parker 8 | * 9 | * See LICENSE.txt for full license information. 10 | */ 11 | package com.hurlant.crypto.hash 12 | { 13 | import flash.utils.ByteArray; 14 | 15 | public interface IHMAC 16 | { 17 | function getHashSize():uint; 18 | /** 19 | * Compute a HMAC using a key and some data. 20 | * It doesn't modify either, and returns a new ByteArray with the HMAC value. 21 | */ 22 | function compute(key:ByteArray, data:ByteArray):ByteArray; 23 | function dispose():void; 24 | function toString():String; 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /src/com/hurlant/crypto/hash/IHash.as: -------------------------------------------------------------------------------- 1 | /** 2 | * IHash 3 | * 4 | * An interface for each hash function to implement 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.crypto.hash 10 | { 11 | import flash.utils.ByteArray; 12 | 13 | public interface IHash 14 | { 15 | function getInputSize():uint; 16 | function getHashSize():uint; 17 | function hash(src:ByteArray):ByteArray; 18 | function toString():String; 19 | function getPadSize():int; 20 | } 21 | } -------------------------------------------------------------------------------- /src/com/hurlant/crypto/hash/SHA224.as: -------------------------------------------------------------------------------- 1 | /** 2 | * SHA224 3 | * 4 | * An ActionScript 3 implementation of Secure Hash Algorithm, SHA-224, as defined 5 | * in FIPS PUB 180-2 6 | * Copyright (c) 2007 Henri Torgemane 7 | * 8 | * See LICENSE.txt for full license information. 9 | */ 10 | package com.hurlant.crypto.hash 11 | { 12 | public class SHA224 extends SHA256 13 | { 14 | function SHA224() { 15 | h = [ 16 | 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 17 | 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 18 | ]; 19 | } 20 | 21 | public override function getHashSize():uint { 22 | return 28; 23 | } 24 | public override function toString():String { 25 | return "sha224"; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/com/hurlant/crypto/hash/SHABase.as: -------------------------------------------------------------------------------- 1 | /** 2 | * SHABase 3 | * 4 | * An ActionScript 3 abstract class for the SHA family of hash functions 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.crypto.hash 10 | { 11 | import flash.utils.ByteArray; 12 | import flash.utils.Endian; 13 | 14 | public class SHABase implements IHash 15 | { 16 | public var pad_size:int = 40; 17 | public function getInputSize():uint 18 | { 19 | return 64; 20 | } 21 | 22 | public function getHashSize():uint 23 | { 24 | return 0; 25 | } 26 | 27 | public function getPadSize():int 28 | { 29 | return pad_size; 30 | } 31 | 32 | public function hash(src:ByteArray):ByteArray 33 | { 34 | var savedLength:uint = src.length; 35 | var savedEndian:String = src.endian; 36 | 37 | src.endian = Endian.BIG_ENDIAN; 38 | var len:uint = savedLength *8; 39 | // pad to nearest int. 40 | while (src.length%4!=0) { 41 | src[src.length]=0; 42 | } 43 | // convert ByteArray to an array of uint 44 | src.position=0; 45 | var a:Array = []; 46 | for (var i:uint=0;i=0;--j) { 47 | X[j]++; 48 | if (X[j]!=0) 49 | break; 50 | } 51 | } 52 | } 53 | public function toString():String { 54 | return key.toString()+"-ctr"; 55 | } 56 | 57 | } 58 | } -------------------------------------------------------------------------------- /src/com/hurlant/crypto/symmetric/ECBMode.as: -------------------------------------------------------------------------------- 1 | /** 2 | * ECBMode 3 | * 4 | * An ActionScript 3 implementation of the ECB confidentiality mode 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.crypto.symmetric 10 | { 11 | import flash.utils.ByteArray; 12 | import com.hurlant.util.Memory; 13 | import com.hurlant.util.Hex; 14 | 15 | /** 16 | * ECB mode. 17 | * This uses a padding and a symmetric key. 18 | * If no padding is given, PKCS#5 is used. 19 | */ 20 | public class ECBMode implements IMode, ICipher 21 | { 22 | private var key:ISymmetricKey; 23 | private var padding:IPad; 24 | 25 | public function ECBMode(key:ISymmetricKey, padding:IPad = null) { 26 | this.key = key; 27 | if (padding == null) { 28 | padding = new PKCS5(key.getBlockSize()); 29 | } else { 30 | padding.setBlockSize(key.getBlockSize()); 31 | } 32 | this.padding = padding; 33 | } 34 | 35 | public function getBlockSize():uint { 36 | return key.getBlockSize(); 37 | } 38 | 39 | public function encrypt(src:ByteArray):void { 40 | padding.pad(src); 41 | src.position = 0; 42 | var blockSize:uint = key.getBlockSize(); 43 | var tmp:ByteArray = new ByteArray; 44 | var dst:ByteArray = new ByteArray; 45 | for (var i:uint=0;i0;i--) { 32 | var v:uint = a[a.length-1]; 33 | a.length--; 34 | if (c!=v) throw new Error("PKCS#5:unpad: Invalid padding value. expected ["+c+"], found ["+v+"]"); 35 | } 36 | // that is all. 37 | } 38 | 39 | public function setBlockSize(bs:uint):void { 40 | blockSize = bs; 41 | } 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /src/com/hurlant/crypto/symmetric/SSLPad.as: -------------------------------------------------------------------------------- 1 | /** 2 | * TLSPad 3 | * 4 | * A padding implementation used by TLS 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.crypto.symmetric { 10 | import flash.utils.ByteArray; 11 | import com.hurlant.util.Hex; 12 | import com.hurlant.crypto.tls.TLSError; 13 | 14 | public class SSLPad implements IPad { 15 | private var blockSize:uint; 16 | 17 | public function SSLPad(blockSize:uint=0) { 18 | this.blockSize = blockSize; 19 | } 20 | public function pad(a:ByteArray):void { 21 | var c:uint = blockSize - (a.length+1)%blockSize; 22 | for (var i:uint=0;i<=c;i++) { 23 | a[a.length] = c; 24 | } 25 | 26 | } 27 | public function unpad(a:ByteArray):void { 28 | var c:uint = a.length%blockSize; 29 | if (c!=0) throw new TLSError("SSLPad::unpad: ByteArray.length isn't a multiple of the blockSize", TLSError.bad_record_mac); 30 | c = a[a.length-1]; 31 | for (var i:uint=c;i>0;i--) { 32 | var v:uint = a[a.length-1]; 33 | a.length--; 34 | // But LOOK! SSL 3.0 doesn't care about this, bytes are arbitrary! 35 | // if (c!=v) throw new TLSError("SSLPad:unpad: Invalid padding value. expected ["+c+"], found ["+v+"]", TLSError.bad_record_mac); 36 | } 37 | a.length--; 38 | 39 | } 40 | public function setBlockSize(bs:uint):void { 41 | blockSize = bs; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/com/hurlant/crypto/symmetric/SimpleIVMode.as: -------------------------------------------------------------------------------- 1 | /** 2 | * SimpleIVMode 3 | * 4 | * A convenience class that automatically places the IV 5 | * at the beginning of the encrypted stream, so it doesn't have to 6 | * be handled explicitely. 7 | * Copyright (c) 2007 Henri Torgemane 8 | * 9 | * See LICENSE.txt for full license information. 10 | */ 11 | package com.hurlant.crypto.symmetric 12 | { 13 | import flash.utils.ByteArray; 14 | import com.hurlant.util.Memory; 15 | 16 | public class SimpleIVMode implements IMode, ICipher 17 | { 18 | protected var mode:IVMode; 19 | protected var cipher:ICipher; 20 | 21 | public function SimpleIVMode(mode:IVMode) { 22 | this.mode = mode; 23 | cipher = mode as ICipher; 24 | } 25 | 26 | public function getBlockSize():uint { 27 | return mode.getBlockSize(); 28 | } 29 | 30 | public function dispose():void { 31 | mode.dispose(); 32 | mode = null; 33 | cipher = null; 34 | Memory.gc(); 35 | } 36 | 37 | public function encrypt(src:ByteArray):void { 38 | cipher.encrypt(src); 39 | var tmp:ByteArray = new ByteArray; 40 | tmp.writeBytes(mode.IV); 41 | tmp.writeBytes(src); 42 | src.position=0; 43 | src.writeBytes(tmp); 44 | } 45 | 46 | public function decrypt(src:ByteArray):void { 47 | var tmp:ByteArray = new ByteArray; 48 | tmp.writeBytes(src, 0, getBlockSize()); 49 | mode.IV = tmp; 50 | tmp = new ByteArray; 51 | tmp.writeBytes(src, getBlockSize()); 52 | cipher.decrypt(tmp); 53 | src.length=0; 54 | src.writeBytes(tmp); 55 | } 56 | public function toString():String { 57 | return "simple-"+cipher.toString(); 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /src/com/hurlant/crypto/symmetric/TLSPad.as: -------------------------------------------------------------------------------- 1 | /** 2 | * TLSPad 3 | * 4 | * A padding implementation used by TLS 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.crypto.symmetric { 10 | import flash.utils.ByteArray; 11 | import com.hurlant.util.Hex; 12 | import com.hurlant.crypto.tls.TLSError; 13 | 14 | public class TLSPad implements IPad { 15 | private var blockSize:uint; 16 | 17 | public function TLSPad(blockSize:uint=0) { 18 | this.blockSize = blockSize; 19 | } 20 | public function pad(a:ByteArray):void { 21 | var c:uint = blockSize - (a.length+1)%blockSize; 22 | for (var i:uint=0;i<=c;i++) { 23 | a[a.length] = c; 24 | } 25 | } 26 | public function unpad(a:ByteArray):void { 27 | var c:uint = a.length%blockSize; 28 | if (c!=0) throw new TLSError("TLSPad::unpad: ByteArray.length isn't a multiple of the blockSize", TLSError.bad_record_mac); 29 | c = a[a.length-1]; 30 | for (var i:uint=c;i>0;i--) { 31 | var v:uint = a[a.length-1]; 32 | a.length--; 33 | if (c!=v) throw new TLSError("TLSPad:unpad: Invalid padding value. expected ["+c+"], found ["+v+"]", TLSError.bad_record_mac); 34 | } 35 | a.length--; 36 | // mostly ripped off from PKCS5.as, but with subtle differences 37 | } 38 | public function setBlockSize(bs:uint):void { 39 | blockSize = bs; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/com/hurlant/crypto/symmetric/TripleDESKey.as: -------------------------------------------------------------------------------- 1 | /** 2 | * TripleDESKey 3 | * 4 | * An Actionscript 3 implementation of Triple DES 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * Derived from: 8 | * The Bouncy Castle Crypto package, 9 | * Copyright (c) 2000-2004 The Legion Of The Bouncy Castle 10 | * (http://www.bouncycastle.org) 11 | * 12 | * See LICENSE.txt for full license information. 13 | */ 14 | package com.hurlant.crypto.symmetric 15 | { 16 | import flash.utils.ByteArray; 17 | import com.hurlant.util.Memory; 18 | import com.hurlant.util.Hex; 19 | 20 | public class TripleDESKey extends DESKey 21 | { 22 | protected var encKey2:Array; 23 | protected var encKey3:Array; 24 | protected var decKey2:Array; 25 | protected var decKey3:Array; 26 | 27 | /** 28 | * This supports 2TDES and 3TDES. 29 | * If the key passed is 128 bits, 2TDES is used. 30 | * If the key has 192 bits, 3TDES is used. 31 | * Other key lengths give "undefined" results. 32 | */ 33 | public function TripleDESKey(key:ByteArray) 34 | { 35 | super(key); 36 | encKey2 = generateWorkingKey(false, key, 8); 37 | decKey2 = generateWorkingKey(true, key, 8); 38 | if (key.length>16) { 39 | encKey3 = generateWorkingKey(true, key, 16); 40 | decKey3 = generateWorkingKey(false, key, 16); 41 | } else { 42 | encKey3 = encKey; 43 | decKey3 = decKey; 44 | } 45 | } 46 | 47 | public override function dispose():void 48 | { 49 | super.dispose(); 50 | var i:uint = 0; 51 | if (encKey2!=null) { 52 | for (i=0;i2*m.t) { 54 | return x.mod(m); 55 | } else if (x.compareTo(m)<0) { 56 | return x; 57 | } else { 58 | var r:BigInteger = new BigInteger; 59 | x.copyTo(r); 60 | reduce(r); 61 | return r; 62 | } 63 | } 64 | 65 | /** 66 | * 67 | * @param x = x mod m (HAC 14.42) 68 | * 69 | */ 70 | public function reduce(lx:BigInteger):void 71 | { 72 | var x:BigInteger = lx as BigInteger; 73 | x.drShiftTo(m.t-1,r2); 74 | if (x.t>m.t+1) { 75 | x.t = m.t+1; 76 | x.clamp(); 77 | } 78 | mu.multiplyUpperTo(r2, m.t+1, q3); 79 | m.multiplyLowerTo(q3, m.t+1, r2); 80 | while (x.compareTo(r2)<0) { 81 | x.dAddOffset(1, m.t+1); 82 | } 83 | x.subTo(r2,x); 84 | while (x.compareTo(m)>=0) { 85 | x.subTo(m,x); 86 | } 87 | } 88 | 89 | } 90 | } -------------------------------------------------------------------------------- /src/com/hurlant/math/ClassicReduction.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.math 2 | { 3 | use namespace bi_internal; 4 | 5 | /** 6 | * Modular reduction using "classic" algorithm 7 | */ 8 | internal class ClassicReduction implements IReduction 9 | { 10 | private var m:BigInteger; 11 | public function ClassicReduction(m:BigInteger) { 12 | this.m = m; 13 | } 14 | public function convert(x:BigInteger):BigInteger { 15 | if (x.s<0 || x.compareTo(m)>=0) { 16 | return x.mod(m); 17 | } 18 | return x; 19 | } 20 | public function revert(x:BigInteger):BigInteger { 21 | return x; 22 | } 23 | public function reduce(x:BigInteger):void { 24 | x.divRemTo(m, null,x); 25 | } 26 | public function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void { 27 | x.multiplyTo(y,r); 28 | reduce(r); 29 | } 30 | public function sqrTo(x:BigInteger, r:BigInteger):void { 31 | x.squareTo(r); 32 | reduce(r); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/com/hurlant/math/IReduction.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.math 2 | { 3 | internal interface IReduction 4 | { 5 | function convert(x:BigInteger):BigInteger; 6 | function revert(x:BigInteger):BigInteger; 7 | function reduce(x:BigInteger):void; 8 | function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void; 9 | function sqrTo(x:BigInteger, r:BigInteger):void; 10 | } 11 | } -------------------------------------------------------------------------------- /src/com/hurlant/math/MontgomeryReduction.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.math 2 | { 3 | use namespace bi_internal; 4 | /** 5 | * Montgomery reduction 6 | */ 7 | internal class MontgomeryReduction implements IReduction 8 | { 9 | private var m:BigInteger; 10 | private var mp:int; 11 | private var mpl:int; 12 | private var mph:int; 13 | private var um:int; 14 | private var mt2:int; 15 | public function MontgomeryReduction(m:BigInteger) { 16 | this.m = m; 17 | mp = m.invDigit(); 18 | mpl = mp & 0x7fff; 19 | mph = mp>>15; 20 | um = (1<<(BigInteger.DB-15))-1; 21 | mt2 = 2*m.t; 22 | } 23 | /** 24 | * xR mod m 25 | */ 26 | public function convert(x:BigInteger):BigInteger { 27 | var r:BigInteger = new BigInteger; 28 | x.abs().dlShiftTo(m.t, r); 29 | r.divRemTo(m, null, r); 30 | if (x.s<0 && r.compareTo(BigInteger.ZERO)>0) { 31 | m.subTo(r,r); 32 | } 33 | return r; 34 | } 35 | /** 36 | * x/R mod m 37 | */ 38 | public function revert(x:BigInteger):BigInteger { 39 | var r:BigInteger = new BigInteger; 40 | x.copyTo(r); 41 | reduce(r); 42 | return r; 43 | } 44 | /** 45 | * x = x/R mod m (HAC 14.32) 46 | */ 47 | public function reduce(x:BigInteger):void { 48 | while (x.t<=mt2) { // pad x so am has enough room later 49 | x.a[x.t++] = 0; 50 | } 51 | for (var i:int=0; i>15)*mpl)&um)<<15))&BigInteger.DM; 55 | // use am to combine the multiply-shift-add into one call 56 | j = i+m.t; 57 | x.a[j] += m.am(0, u0, x, i, 0, m.t); 58 | // propagate carry 59 | while (x.a[j]>=BigInteger.DV) { 60 | x.a[j] -= BigInteger.DV; 61 | x.a[++j]++; 62 | } 63 | } 64 | x.clamp(); 65 | x.drShiftTo(m.t, x); 66 | if (x.compareTo(m)>=0) { 67 | x.subTo(m,x); 68 | } 69 | } 70 | /** 71 | * r = "x^2/R mod m"; x != r 72 | */ 73 | public function sqrTo(x:BigInteger, r:BigInteger):void { 74 | x.squareTo(r); 75 | reduce(r); 76 | } 77 | /** 78 | * r = "xy/R mod m"; x,y != r 79 | */ 80 | public function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void { 81 | x.multiplyTo(y,r); 82 | reduce(r); 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /src/com/hurlant/math/NullReduction.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.math 2 | { 3 | use namespace bi_internal; 4 | /** 5 | * A "null" reducer 6 | */ 7 | public class NullReduction implements IReduction 8 | { 9 | public function revert(x:BigInteger):BigInteger 10 | { 11 | return x; 12 | } 13 | 14 | public function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void 15 | { 16 | x.multiplyTo(y,r); 17 | } 18 | 19 | public function sqrTo(x:BigInteger, r:BigInteger):void 20 | { 21 | x.squareTo(r); 22 | } 23 | 24 | public function convert(x:BigInteger):BigInteger 25 | { 26 | return x; 27 | } 28 | 29 | public function reduce(x:BigInteger):void 30 | { 31 | } 32 | 33 | } 34 | } -------------------------------------------------------------------------------- /src/com/hurlant/math/bi_internal.as: -------------------------------------------------------------------------------- 1 | /** 2 | * bi_internal 3 | * 4 | * A namespace. w00t. 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.math { 10 | public namespace bi_internal = "http://crypto.hurlant.com/BigInteger"; 11 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/ArrayUtil.as: -------------------------------------------------------------------------------- 1 | /** 2 | * ArrayUtil 3 | * 4 | * A class that allows to compare two ByteArrays. 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.util { 10 | import flash.utils.ByteArray; 11 | 12 | 13 | public class ArrayUtil { 14 | 15 | public static function equals(a1:ByteArray, a2:ByteArray):Boolean { 16 | if (a1.length != a2.length) return false; 17 | var l:int = a1.length; 18 | for (var i:int=0;i0?p.join("."):null; 7 | return new OIDType(s); 8 | } 9 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/parser/optional.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.parser { 2 | import com.hurlant.util.asn1.type.ASN1Type; 3 | 4 | public function optional(o:ASN1Type):ASN1Type { 5 | o = o.clone(); 6 | o.optional = true; 7 | return o; 8 | } 9 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/parser/printableString.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.parser { 2 | import com.hurlant.util.asn1.type.ASN1Type; 3 | import com.hurlant.util.asn1.type.PrintableStringType; 4 | 5 | public function printableString(size:int=int.MAX_VALUE,size2:int=0):ASN1Type { 6 | return new PrintableStringType(size, size2); 7 | } 8 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/parser/sequence.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.parser { 2 | import com.hurlant.util.asn1.type.ASN1Type; 3 | import com.hurlant.util.asn1.type.SequenceType; 4 | 5 | public function sequence(...p):ASN1Type { 6 | var a:Array = []; 7 | for (var i:int=0;i0) { 39 | o = s.readUnsignedByte(); 40 | var last:Boolean = (o&0x80)==0; 41 | o &= 0x7f; 42 | v = v*128 + o; 43 | if (last) { 44 | a.push(v); 45 | v = 0; 46 | } 47 | } 48 | var str:String = a.join("."); 49 | if (oid!=null) { 50 | if (oid==str) { 51 | return this.clone(); 52 | } else { 53 | s.position = p; 54 | return null; 55 | } 56 | } else { 57 | return new OIDType(str); 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/type/OctetStringType.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.type { 2 | import flash.net.registerClassAlias; 3 | import flash.utils.ByteArray; 4 | 5 | public class OctetStringType extends ASN1Type { 6 | registerClassAlias("com.hurlant.util.asn1.parser.OctetStringType", OctetStringType); 7 | 8 | public function OctetStringType() { 9 | super(ASN1Type.OCTET_STRING); 10 | } 11 | 12 | protected override function fromDERContent(s:ByteArray, length:int):* { 13 | var b:ByteArray = new ByteArray; 14 | s.readBytes(b, 0, length); 15 | return b; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/type/PrintableStringType.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.type { 2 | import flash.net.registerClassAlias; 3 | 4 | public class PrintableStringType extends StringType { 5 | registerClassAlias("com.hurlant.util.asn1.PrintableStringType", PrintableStringType); 6 | 7 | public function PrintableStringType(size1:int=int.MAX_VALUE, size2:int=0) { 8 | super(ASN1Type.PRINTABLE_STRING, size1, size2); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/type/SequenceType.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.type { 2 | import flash.net.registerClassAlias; 3 | import flash.utils.ByteArray; 4 | 5 | public class SequenceType extends ASN1Type { 6 | registerClassAlias("com.hurlant.util.asn1.SequenceType", SequenceType); 7 | 8 | public var children:Array; 9 | public var childType:ASN1Type; 10 | 11 | public function SequenceType(p:* = null) { 12 | super(ASN1Type.SEQUENCE); 13 | if (p is Array) { 14 | children = p as Array; 15 | } else { 16 | childType = p as ASN1Type; 17 | } 18 | } 19 | 20 | protected override function fromDERContent(s:ByteArray, length:int):* { 21 | var p:int = s.position; 22 | var left:int = length; 23 | var val:*, v:*; // v=individual children, val=entire sequence 24 | if (children!=null) { 25 | // sequence 26 | val = {}; 27 | for (var i:int=0;i0) { 56 | v = childType.fromDER(s, left); 57 | if (v==null) { 58 | throw new Error("couldn't parse DER stream."); 59 | } else { 60 | val.push(v); 61 | } 62 | left = length - s.position + p; 63 | } 64 | return val; 65 | } 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/type/SetType.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.type { 2 | import flash.net.registerClassAlias; 3 | import flash.utils.ByteArray; 4 | 5 | public class SetType extends ASN1Type { 6 | registerClassAlias("com.hurlant.util.asn1.SetType", SetType); 7 | 8 | public var childType:ASN1Type; 9 | 10 | public function SetType(p:ASN1Type = null) { 11 | super(ASN1Type.SET); 12 | childType = p; 13 | } 14 | 15 | protected override function fromDERContent(s:ByteArray, length:int):* { 16 | var p:int = s.position; 17 | var left:int = length; 18 | var val:Array, v:*; // v=individual children, val=entire set 19 | val = []; // unordered in theory, but this will do. 20 | while (left>0) { 21 | v = childType.fromDER(s, left); 22 | if (v==null) { 23 | throw new Error("couldn't parse DER stream."); 24 | } else { 25 | val.push(v); 26 | } 27 | left = length - s.position + p; 28 | } 29 | return val; 30 | } 31 | 32 | } 33 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/type/StringType.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.type { 2 | import flash.net.registerClassAlias; 3 | import flash.utils.ByteArray; 4 | 5 | public class StringType extends ASN1Type { 6 | registerClassAlias("com.hurlant.util.asn1.StringType", StringType); 7 | 8 | public var size1:int, size2:int; 9 | 10 | public function StringType(tag:int, size1:int=int.MAX_VALUE, size2:int=0) { 11 | super(tag); 12 | this.size1 = size1; 13 | this.size2 = size2; 14 | } 15 | 16 | protected override function fromDERContent(s:ByteArray, length:int):* { 17 | // XXX insufficient 18 | var str:String = s.readMultiByte(length, "US-ASCII"); 19 | return str; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/type/TeletexStringType.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.type { 2 | import flash.net.registerClassAlias; 3 | 4 | public class TeletexStringType extends StringType { 5 | registerClassAlias("com.hurlant.util.asn1.TeletexStringType", TeletexStringType); 6 | 7 | public function TeletexStringType(size1:int=int.MAX_VALUE, size2:int=0) { 8 | super(ASN1Type.TELETEX_STRING, size1, size2); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/type/UTCTimeType.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.type { 2 | import flash.net.registerClassAlias; 3 | import flash.utils.ByteArray; 4 | 5 | public class UTCTimeType extends ASN1Type { 6 | registerClassAlias("com.hurlant.util.asn1.UTCTime", UTCTimeType); 7 | 8 | public function UTCTimeType() { 9 | super(ASN1Type.UTC_TIME); 10 | } 11 | 12 | protected override function fromDERContent(s:ByteArray, length:int):* { 13 | // XXX insufficient 14 | var str:String = s.readMultiByte(length, "US-ASCII"); 15 | 16 | var year:uint = parseInt(str.substr(0, 2)); 17 | if (year<50) { 18 | year+=2000; 19 | } else { 20 | year+=1900; 21 | } 22 | var month:uint = parseInt(str.substr(2,2)); 23 | var day:uint = parseInt(str.substr(4,2)); 24 | var hour:uint = parseInt(str.substr(6,2)); 25 | var minute:uint = parseInt(str.substr(8,2)); 26 | // XXX this could be off by up to a day. parse the rest. someday. 27 | return new Date(year, month-1, day, hour, minute); 28 | } 29 | 30 | } 31 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/type/UTF8StringType.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.type { 2 | import flash.net.registerClassAlias; 3 | 4 | public class UTF8StringType extends StringType { 5 | registerClassAlias("com.hurlant.util.asn1.UTF8String", UTF8StringType); 6 | 7 | public function UTF8StringType(size1:int=int.MAX_VALUE, size2:int=0) { 8 | super(ASN1Type.UTF8STRING, size1, size2); 9 | } 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/asn1/type/UniversalStringType.as: -------------------------------------------------------------------------------- 1 | package com.hurlant.util.asn1.type { 2 | import flash.net.registerClassAlias; 3 | 4 | public class UniversalStringType extends StringType { 5 | registerClassAlias("com.hurlant.util.asn1.UniversalStringType", UniversalStringType); 6 | 7 | public function UniversalStringType(size1:int=int.MAX_VALUE, size2:int=0) { 8 | super(ASN1Type.UNIVERSAL_STRING, size1, size2); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/der/ByteString.as: -------------------------------------------------------------------------------- 1 | /** 2 | * ByteString 3 | * 4 | * An ASN1 type for a ByteString, represented with a ByteArray 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.util.der 10 | { 11 | import flash.utils.ByteArray; 12 | import com.hurlant.util.Hex; 13 | 14 | public class ByteString extends ByteArray implements IAsn1Type 15 | { 16 | private var type:uint; 17 | private var len:uint; 18 | 19 | public function ByteString(type:uint = 0x04, length:uint = 0x00) { 20 | this.type = type; 21 | this.len = length; 22 | } 23 | 24 | public function getLength():uint 25 | { 26 | return len; 27 | } 28 | 29 | public function getType():uint 30 | { 31 | return type; 32 | } 33 | 34 | public function toDER():ByteArray { 35 | return DER.wrapDER(type, this); 36 | } 37 | 38 | override public function toString():String { 39 | return DER.indent+"ByteString["+type+"]["+len+"]["+Hex.fromArray(this)+"]"; 40 | } 41 | 42 | } 43 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/der/IAsn1Type.as: -------------------------------------------------------------------------------- 1 | /** 2 | * IAsn1Type 3 | * 4 | * An interface for Asn-1 types. 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.util.der 10 | { 11 | import flash.utils.ByteArray; 12 | 13 | public interface IAsn1Type 14 | { 15 | function getType():uint; 16 | function getLength():uint; 17 | 18 | function toDER():ByteArray; 19 | 20 | } 21 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/der/Integer.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Integer 3 | * 4 | * An ASN1 type for an Integer, represented with a BigInteger 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.util.der 10 | { 11 | import com.hurlant.math.BigInteger; 12 | import flash.utils.ByteArray; 13 | 14 | public class Integer extends BigInteger implements IAsn1Type 15 | { 16 | private var type:uint; 17 | private var len:uint; 18 | 19 | public function Integer(type:uint, length:uint, b:ByteArray) { 20 | this.type = type; 21 | this.len = length; 22 | super(b); 23 | } 24 | 25 | public function getLength():uint 26 | { 27 | return len; 28 | } 29 | 30 | public function getType():uint 31 | { 32 | return type; 33 | } 34 | 35 | override public function toString(radix:Number=0):String { 36 | return DER.indent+"Integer["+type+"]["+len+"]["+super.toString(16)+"]"; 37 | } 38 | 39 | public function toDER():ByteArray { 40 | return null; 41 | } 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/der/OID.as: -------------------------------------------------------------------------------- 1 | /** 2 | * OID 3 | * 4 | * A list of various ObjectIdentifiers. 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.util.der 10 | { 11 | public class OID 12 | { 13 | 14 | public static const RSA_ENCRYPTION:String = "1.2.840.113549.1.1.1"; 15 | public static const MD2_WITH_RSA_ENCRYPTION:String = "1.2.840.113549.1.1.2"; 16 | public static const MD5_WITH_RSA_ENCRYPTION:String = "1.2.840.113549.1.1.4"; 17 | public static const SHA1_WITH_RSA_ENCRYPTION:String = "1.2.840.113549.1.1.5"; 18 | public static const MD2_ALGORITHM:String = "1.2.840.113549.2.2"; 19 | public static const MD5_ALGORITHM:String = "1.2.840.113549.2.5"; 20 | public static const PKCS9_UNSTRUCTURED_NAME:String = "1.2.840.113549.1.9.2"; 21 | public static const DSA:String = "1.2.840.10040.4.1"; 22 | public static const DSA_WITH_SHA1:String = "1.2.840.10040.4.3"; 23 | public static const DH_PUBLIC_NUMBER:String = "1.2.840.10046.2.1"; 24 | public static const SHA1_ALGORITHM:String = "1.3.14.3.2.26"; 25 | 26 | public static const COMMON_NAME:String = "2.5.4.3"; 27 | public static const SURNAME:String = "2.5.4.4"; 28 | public static const COUNTRY_NAME:String = "2.5.4.6"; 29 | public static const LOCALITY_NAME:String = "2.5.4.7"; 30 | public static const STATE_NAME:String = "2.5.4.8"; 31 | public static const ORGANIZATION_NAME:String = "2.5.4.10"; 32 | public static const ORG_UNIT_NAME:String = "2.5.4.11"; 33 | public static const TITLE:String = "2.5.4.12"; 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/der/PrintableString.as: -------------------------------------------------------------------------------- 1 | /** 2 | * PrintableString 3 | * 4 | * An ASN1 type for a PrintableString, held within a String 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.util.der 10 | { 11 | import flash.utils.ByteArray; 12 | 13 | public class PrintableString implements IAsn1Type 14 | { 15 | protected var type:uint; 16 | protected var len:uint; 17 | protected var str:String; 18 | 19 | public function PrintableString(type:uint, length:uint) { 20 | this.type = type; 21 | this.len = length; 22 | } 23 | 24 | public function getLength():uint 25 | { 26 | return len; 27 | } 28 | 29 | public function getType():uint 30 | { 31 | return type; 32 | } 33 | 34 | public function setString(s:String):void { 35 | str = s; 36 | } 37 | public function getString():String { 38 | return str; 39 | } 40 | 41 | public function toString():String { 42 | return DER.indent+str; 43 | } 44 | 45 | public function toDER():ByteArray { 46 | return null; // XXX not implemented 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/com/hurlant/util/der/Sequence.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Sequence 3 | * 4 | * An ASN1 type for a Sequence, implemented as an Array 5 | * Copyright (c) 2007 Henri Torgemane 6 | * 7 | * See LICENSE.txt for full license information. 8 | */ 9 | package com.hurlant.util.der 10 | { 11 | import flash.utils.ByteArray; 12 | 13 | public dynamic class Sequence extends Array implements IAsn1Type 14 | { 15 | protected var type:uint; 16 | protected var len:uint; 17 | 18 | public function Sequence(type:uint = 0x30, length:uint = 0x00) { 19 | this.type = type; 20 | this.len = length; 21 | } 22 | 23 | public function getLength():uint 24 | { 25 | return len; 26 | } 27 | 28 | public function getType():uint 29 | { 30 | return type; 31 | } 32 | 33 | public function toDER():ByteArray { 34 | var tmp:ByteArray = new ByteArray; 35 | for (var i:int=0;iAuthor: Romuald Quantin - www.soundstep.com
* Company: Less Rain - www.lessrain.com
* Class version: 1.0
* Actionscript version: 3.0
* Copyright: *
* Date: Feb 17, 2010
* Usage: * @example * */ public class PropertiesUI { //------------------------------------ // private, protected properties //------------------------------------ //------------------------------------ // public properties //------------------------------------ public var x:Number; public var y:Number; public var width:Number; public var height:Number; //------------------------------------ // constructor //------------------------------------ public function PropertiesUI(x:Number = NaN, y:Number = NaN, width:Number = NaN, height:Number = NaN) { this.x = x; this.y = y; this.width = width; this.height = height; } // // PRIVATE, PROTECTED //________________________________________________________________________________________________ // PUBLIC //________________________________________________________________________________________________ public function toString():String { return "[PropertiesUI] " + "x: " + x + ", y: " + y + ", width: " + width + ", height: " + height; } } } -------------------------------------------------------------------------------- /src/gnu/as3/gettext/AsGettext.as: -------------------------------------------------------------------------------- 1 | /* 2 | * AsGettext.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | 24 | /** 25 | * The global _Gettext object. 26 | */ 27 | public const AsGettext:_Gettext = new _Gettext(gnu.as3.gettext.Locale); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/Domain.as: -------------------------------------------------------------------------------- 1 | /* 2 | * Domain.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | 24 | import flash.utils.Dictionary; 25 | 26 | /** 27 | * Holds data about a domain 28 | */ 29 | public class Domain 30 | { 31 | // locale/MOFile 32 | public var catalogs:Dictionary; 33 | 34 | /** 35 | * The locations associated to the domains. 36 | */ 37 | public var binding:String; 38 | 39 | public var name:String; 40 | 41 | public function Domain(name:String, binding:String, catalogs:Dictionary = null) 42 | { 43 | this.name = name; 44 | this.binding = binding; 45 | this.catalogs = catalogs || new Dictionary(); 46 | } 47 | 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/FxGettext.as: -------------------------------------------------------------------------------- 1 | /* 2 | * FxGettext.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | 24 | /** 25 | * The global _FxGettext object. 26 | */ 27 | public const FxGettext:_FxGettext = new _FxGettext(gnu.as3.gettext.Locale); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/GettextError.as: -------------------------------------------------------------------------------- 1 | /* 2 | * GettextError.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | 24 | /** 25 | * GettextError errors are typical errors used in the 26 | * Actionscript GNU Gettext library. 27 | */ 28 | public class GettextError extends Error 29 | { 30 | public function GettextError(message:String,id:int = 0) 31 | { 32 | super(message,id); 33 | } 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/ISO_3166.as: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrong/as3/d824d10471ebdc7eaa7573bfa9b9e44cbc009208/src/gnu/as3/gettext/ISO_3166.as -------------------------------------------------------------------------------- /src/gnu/as3/gettext/ISO_639_1.as: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrong/as3/d824d10471ebdc7eaa7573bfa9b9e44cbc009208/src/gnu/as3/gettext/ISO_639_1.as -------------------------------------------------------------------------------- /src/gnu/as3/gettext/Locale.as: -------------------------------------------------------------------------------- 1 | /* 2 | * Locale.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | 24 | /** 25 | * The global _Locale object. 26 | */ 27 | public const Locale:_Locale = new _Locale(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/PACKAGE.as: -------------------------------------------------------------------------------- 1 | /* 2 | * PACKAGE.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | /** 24 | * The name of this library package. 25 | */ 26 | public const PACKAGE:String = "libas3gnugettext"; 27 | } 28 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/_.as: -------------------------------------------------------------------------------- 1 | /* 2 | * _.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | 24 | /** 25 | * @private 26 | * internal alias of dgettext. 27 | */ 28 | internal function _(string:String):String 29 | { 30 | return dgettext(PACKAGE, string); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/_FxGettext.as: -------------------------------------------------------------------------------- 1 | /* 2 | * _FxGettext.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | 24 | import flash.events.Event; 25 | 26 | public class _FxGettext extends _Gettext 27 | { 28 | 29 | public function _FxGettext(locale:_Locale) 30 | { 31 | super(locale); 32 | } 33 | 34 | /** 35 | * @inheritDoc 36 | */ 37 | [Bindable("complete")] 38 | override public function gettext(string:String):String 39 | { 40 | return super.gettext(string); 41 | } 42 | 43 | /** 44 | * @copy #gettext() 45 | */ 46 | [Bindable("complete")] 47 | public function _(string:String):String 48 | { 49 | return super.gettext(string); 50 | } 51 | 52 | /** 53 | * @inheritDoc 54 | */ 55 | [Bindable("complete")] 56 | override public function dgettext(domain:String, string:String):String 57 | { 58 | return super.dgettext(domain,string); 59 | } 60 | 61 | /** 62 | * @copy #dgettext() 63 | */ 64 | [Bindable("complete")] 65 | public function _d(domain:String, string:String):String 66 | { 67 | return super.dgettext(domain,string); 68 | } 69 | 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/dgettext.as: -------------------------------------------------------------------------------- 1 | /* 2 | * dgettext.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | 24 | /** 25 | * An alias of AsGettext.dgettext(). 26 | * @see _Gettext#dgettext() 27 | */ 28 | public const dgettext:Function = AsGettext.dgettext; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/gettext.as: -------------------------------------------------------------------------------- 1 | /* 2 | * gettext.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | 24 | /** 25 | * An alias of AsGettext.gettext(). 26 | * @see _Gettext#gettext() 27 | */ 28 | public const gettext:Function = AsGettext.gettext; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/gettext_noop.as: -------------------------------------------------------------------------------- 1 | /* 2 | * gettext_noop.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | 24 | /** 25 | * An alias of AsGettext.gettext_noop(). 26 | * @see _Gettext#gettext_noop() 27 | */ 28 | public const gettext_noop:Function = AsGettext.gettext_noop; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/services/IGettextService.as: -------------------------------------------------------------------------------- 1 | /* 2 | * IGettextService.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext.services 22 | { 23 | 24 | import flash.events.IEventDispatcher; 25 | 26 | import gnu.as3.gettext.MOFile; 27 | 28 | /** 29 | * A service to load a catalog. Dispatches a complete or an ioError events. 30 | */ 31 | public interface IGettextService extends IEventDispatcher 32 | { 33 | function get domainName():String; 34 | function get catalog():MOFile; 35 | function get baseURL():String; 36 | function get locale():String; 37 | function clone():IGettextService; 38 | 39 | function load(path:String, domainName:String, locale:String):void; 40 | function reset():void; 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/services/_.as: -------------------------------------------------------------------------------- 1 | /* 2 | * _.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext.services 22 | { 23 | 24 | import gnu.as3.gettext.dgettext; 25 | import gnu.as3.gettext.PACKAGE; 26 | 27 | /** 28 | * @private 29 | * internal alias of dgettext. 30 | */ 31 | internal function _(string:String):String 32 | { 33 | return dgettext(PACKAGE, string); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/gnu/as3/gettext/sprintf.as: -------------------------------------------------------------------------------- 1 | /* 2 | * sprintf.as 3 | * This file is part of Actionscript GNU Gettext 4 | * 5 | * Copyright (C) 2010 - Vincent Petithory 6 | * 7 | * Actionscript GNU Gettext is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * Actionscript GNU Gettext is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | package gnu.as3.gettext 22 | { 23 | 24 | /** 25 | * Formats the specified string, using the specified values. 26 | * 27 | * @param str The string to format. 28 | * @param values A collection of values to insert. 29 | * It can be an Array, Vector, Dictionary, Object, or any object that 30 | * matches the keys of the string. 31 | * @return The formatted string. 32 | */ 33 | public function sprintf(string:String, values:* = null):String 34 | { 35 | regexpValues = values; 36 | var stringOut:String = string.replace(tokenPattern, repFunc); 37 | regexpValues = null; 38 | return stringOut; 39 | } 40 | 41 | } 42 | 43 | /** 44 | * Defines the pattern that token-based functions 45 | * use to manipulate strings. 46 | */ 47 | internal const tokenPattern:RegExp = /{[\d|\w]+}/g; 48 | 49 | /** 50 | * @private 51 | */ 52 | internal var regexpValues:*; 53 | 54 | /** 55 | * @private 56 | */ 57 | internal const repFunc:Function = function():String 58 | { 59 | var token:String = arguments[0]; 60 | return String(regexpValues[token.substring(1,token.length-1)]); 61 | } 62 | -------------------------------------------------------------------------------- /src/manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/org/zengrong/air/utils/getDesc.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.air.utils 2 | { 3 | import flash.desktop.NativeApplication; 4 | 5 | public function getDesc($name:String):String 6 | { 7 | var __desc:XML = NativeApplication.nativeApplication.applicationDescriptor; 8 | var __ns:Namespace = __desc.namespace(); 9 | return __desc.__ns::[$name]; 10 | } 11 | } -------------------------------------------------------------------------------- /src/org/zengrong/assets/AssetsEvent.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong 4 | // 创建时间:2012-03-06 5 | // 最后修改:2012-03-06 6 | //////////////////////////////////////////////////////////////////////////////// 7 | package org.zengrong.assets 8 | { 9 | import flash.events.Event; 10 | 11 | import org.zengrong.assets.AssetsProgressVO; 12 | 13 | /** 14 | * 用于Assets类在载入过程中发出的事件 15 | * @author zrong 16 | * @see org.zengrong.assets.Assets 17 | */ 18 | public class AssetsEvent extends Event 19 | { 20 | /** 21 | * 资源载入完成事件 22 | * @eventType complete 23 | */ 24 | public static const COMPLETE:String = 'complete'; 25 | 26 | /** 27 | * 碰到载入错误等需要发送信息 28 | * @eventType info 29 | */ 30 | public static const INFO:String = 'info'; 31 | 32 | /** 33 | * 处理事件 34 | * @eventType progress 35 | */ 36 | public static const PROGRESS:String = 'progress'; 37 | 38 | public function AssetsEvent($type:String, $vo:AssetsProgressVO=null, $bubbles:Boolean=false, $cancelable:Boolean=false) 39 | { 40 | super($type, $bubbles, $cancelable); 41 | vo = $vo; 42 | } 43 | 44 | public var vo:AssetsProgressVO; 45 | 46 | public var info:String; 47 | 48 | override public function clone():Event 49 | { 50 | return new AssetsEvent(type, vo, bubbles, cancelable); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /src/org/zengrong/assets/AssetsProgressVO.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong 4 | // 创建时间:2011-04-27 5 | // 修改时间:2011-09-07 6 | //////////////////////////////////////////////////////////////////////////////// 7 | package org.zengrong.assets 8 | { 9 | /** 10 | * Assets载入过程中,调用Progress回调函数的参数的ValueObject 11 | * @author zrong 12 | */ 13 | public class AssetsProgressVO 14 | { 15 | public function AssetsProgressVO($curFile:Object=null) 16 | { 17 | if($curFile) 18 | { 19 | name = $curFile.fname; 20 | url = $curFile.url; 21 | ftype = $curFile.ftype; 22 | otype = $curFile.otype; 23 | if($curFile.loaded!=undefined) 24 | loaded = $curFile.loaded; 25 | if($curFile.total!=undefined) 26 | total = $curFile.total; 27 | if($curFile.whole!=undefined) 28 | whole = $curFile.whole; 29 | } 30 | } 31 | 32 | /** 33 | * 若值为true,代表载入列表的进度;否则就是当前文件的载入进度 34 | */ 35 | public var whole:Boolean; 36 | 37 | /** 38 | * 若值为true,代表这次载入完成;否则代表载入没有完成。
39 | * 这个值与whole联用,主要针对载入列表的进度。 40 | * 这个值当whole为true的时候才有意义,当whole为false的时候,这个值始终为false。
41 | * 在载入列表进度事件发生的时候,whole总是为true。
42 | * 对于列表中一个资源的载入,在开始载入和载入成功的时候会各发送一次progress事件。 43 | * 开始载入的时候,done值为false;载入成功的时候,done值为true。
44 | */ 45 | public var done:Boolean; 46 | 47 | /** 48 | * 载入的总量 49 | */ 50 | public var total:int; 51 | 52 | /** 53 | * 当前载入量 54 | */ 55 | public var loaded:int; 56 | 57 | /** 58 | * 正在载入的资源的名称 59 | */ 60 | public var name:String; 61 | 62 | /** 63 | * 正在载入的资源的url 64 | */ 65 | public var url:String; 66 | 67 | /** 68 | * 正在载入的资源的文件类型 69 | */ 70 | public var ftype:String; 71 | 72 | /** 73 | * 正在载入的资源的职责类型 74 | */ 75 | public var otype:String; 76 | 77 | public function toString():String 78 | { 79 | return 'org.zengrong.assets::AssetsProgressVO{'+ 80 | 'name:'+name+ 81 | ',url:'+url+ 82 | ',ftype:'+ftype+ 83 | ',otype:'+otype+ 84 | ',loaded:'+loaded+ 85 | ',total:'+total+ 86 | ',whole:'+whole + 87 | ',done:'+done+ '}'; 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/org/zengrong/display/character/ActionLabel.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong(zrongzrong@gmail.com) 4 | // 最后更新时间:2011-08-03 5 | //////////////////////////////////////////////////////////////////////////////// 6 | package org.zengrong.display.character 7 | { 8 | 9 | /** 10 | * 保存角色动作的所有可用Label 11 | */ 12 | public class ActionLabel 13 | { 14 | //----------------------------------------允许调用并支持返回调用的动作 15 | /** 16 | * 被击中的动作 17 | */ 18 | public static const HIT:String = 'hit'; 19 | 20 | /** 21 | * 死亡的动作 22 | */ 23 | public static const DEAD:String = 'dead'; 24 | 25 | /** 26 | * 攻击别人的动作 27 | */ 28 | public static const ATTACK:String = 'attack'; 29 | 30 | /** 31 | * 释放技能的动作 32 | */ 33 | public static const SKILL:String = 'skill'; 34 | 35 | //----------------------------------------允许调用,但不支持返回调用的动作 36 | /** 37 | * 闪避的动作 38 | */ 39 | public static const MISS:String = 'miss'; 40 | 41 | /** 42 | * 90度站立的动作 43 | */ 44 | public static const STAND:String = 'stand'; 45 | 46 | /** 47 | * 跑动的动作 48 | */ 49 | public static const RUN:String = 'run'; 50 | 51 | /** 52 | * 45度站立的动作 53 | */ 54 | public static const STAND45:String = 'stand45'; 55 | 56 | /** 57 | * 45度站立,但没有影子 58 | */ 59 | public static const STAND45NO:String = 'stand45no'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/org/zengrong/display/spritesheet/MaskType.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong 4 | // 创建时间:2011-04-14 5 | //////////////////////////////////////////////////////////////////////////////// 6 | package org.zengrong.display.spritesheet 7 | { 8 | /** 9 | * 定义图像中是否包含MASK的值 10 | * @author zrong 11 | */ 12 | public class MaskType 13 | { 14 | /** 15 | * 没有MASK 16 | */ 17 | public static const NO_MASK:int = 0; 18 | 19 | /** 20 | * 横向MASK 21 | */ 22 | public static const HOR_MASK:int = 1; 23 | 24 | /** 25 | * 纵向MASK 26 | */ 27 | public static const VER_MASK:int = 2; 28 | 29 | public static function isMaskType($type:int):Boolean 30 | { 31 | return $type == NO_MASK || $type == HOR_MASK || $type == VER_MASK; 32 | } 33 | 34 | public static function useMask($type:int):Boolean 35 | { 36 | return $type == HOR_MASK || $type == VER_MASK; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/org/zengrong/display/spritesheet/SpriteSheetMetadataStarling.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.display.spritesheet 2 | { 3 | import flash.geom.Rectangle; 4 | 5 | /** 6 | * SpriteSheetMetadata的XML格式包装器 7 | * @author zrong (http://zengrong.net) 8 | * 创建日期:2013-4-6 9 | */ 10 | public class SpriteSheetMetadataStarling extends SpriteSheetMetadataStringWraper 11 | { 12 | public function SpriteSheetMetadataStarling($meta:ISpriteSheetMetadata) 13 | { 14 | super($meta); 15 | } 16 | 17 | /** 18 | * XML格式的换行符 19 | * 将XML文本化的方法,是调用XML.toXMLString转换XML字符串,而XML.toXMLString默认使用\n作为换行符。所以这里使用自定义换行符意义不大,反而可能会造成换行符混乱。 20 | */ 21 | override public function get lineEnding():String 22 | { 23 | return super.lineEnding; 24 | } 25 | 26 | private var _header:String = '\n'; 27 | 28 | /** 29 | * 设置XML的Header内容 30 | */ 31 | public function get header():String 32 | { 33 | return _header; 34 | } 35 | 36 | public function set header($value:String):void 37 | { 38 | _header = $value; 39 | } 40 | 41 | 42 | /** 43 | * 从Starling 的XML文件解析Metadata数据 44 | * TODO 等待实现 45 | * 46 | * @param $xml Starling格式的SpriteSheet XML文件 47 | */ 48 | override public function parse($value:*):ISpriteSheetMetadata 49 | { 50 | var __xml:XML = $value; 51 | return null; 52 | } 53 | 54 | /** 55 | * @inheritDoc 56 | */ 57 | override public function objectify($isSimple:Boolean=false, $includeName:Boolean=true, ...$args):* 58 | { 59 | var __xml:XML = toXML($isSimple, $includeName); 60 | if($args.length > 0 && ($args[0] is String)) 61 | { 62 | __xml.@imagePath = String($args[0]); 63 | } 64 | return header + __xml.toXMLString(); 65 | } 66 | 67 | private function toXML($isSimple:Boolean, $includeName:Boolean):XML 68 | { 69 | var __xml:XML = ; 70 | var i:int=0; 71 | var __name:String = null; 72 | for(i=0;i; 86 | if($name) __xml.@name = $name; 87 | __xml.@x = $sizeRect.x; 88 | __xml.@y = $sizeRect.y; 89 | __xml.@width = $sizeRect.width; 90 | __xml.@height = $sizeRect.height; 91 | __xml.@frameX = $originRect.x; 92 | __xml.@frameY = $originRect.y; 93 | __xml.@frameWeight = $originRect.width; 94 | __xml.@frameHeight = $originRect.height; 95 | return __xml; 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /src/org/zengrong/display/spritesheet/SpriteSheetMetadataStringWraper.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.display.spritesheet 2 | { 3 | /** 4 | * 输出格式为纯文本的包装器,需要实现lineEnding 5 | * @author zrong (http://zengrong.net) 6 | * 创建日期:2013-4-7 7 | */ 8 | public class SpriteSheetMetadataStringWraper extends SpriteSheetMetadataWrapper 9 | { 10 | public function SpriteSheetMetadataStringWraper($meta:ISpriteSheetMetadata) 11 | { 12 | super($meta); 13 | } 14 | 15 | private var _lineEnding:String = "\n"; 16 | 17 | /** 18 | * 文本换行符 19 | * 20 | * @defaults \n 21 | */ 22 | public function get lineEnding():String 23 | { 24 | return _lineEnding; 25 | } 26 | 27 | /** 28 | * @private 29 | */ 30 | public function set lineEnding($value:String):void 31 | { 32 | _lineEnding = $value; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/org/zengrong/display/spritesheet/SpriteSheetMetadataType.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong 4 | // 创建时间:2011-08-24 5 | //////////////////////////////////////////////////////////////////////////////// 6 | package org.zengrong.display.spritesheet 7 | { 8 | /** 9 | * 定义SpriteSheetMetadata的文件类型 10 | */ 11 | public class SpriteSheetMetadataType 12 | { 13 | public static const XML:String = 'xml'; 14 | public static const JSON:String = 'json'; 15 | public static const BINARY:String = 'binary'; 16 | public static const TXT:String = 'txt'; 17 | public static const PLIST:String = 'plist'; 18 | 19 | /** 20 | * SpriteSheetEditor的原生格式,存储为XML 21 | */ 22 | public static const SSE_XML:String = "ssexml"; 23 | 24 | /** 25 | * SpriteSheetEditor的原生格式,存储为JSON 26 | */ 27 | public static const SSE_JSON:String = "ssejson"; 28 | 29 | /** 30 | * SpriteSheetEditor的原生格式,存储为TXT 31 | */ 32 | public static const SSE_TXT:String = "ssetxt"; 33 | 34 | /** 35 | * Starling格式 36 | */ 37 | public static const STARLING:String = "starling"; 38 | 39 | /** 40 | * Cocos2d格式 41 | */ 42 | public static const COCOS2D:String = "cocos2d"; 43 | 44 | public static function getTypeExt($typeName:String):String 45 | { 46 | switch($typeName) 47 | { 48 | case SSE_XML: 49 | return XML; 50 | break; 51 | case SSE_JSON: 52 | return JSON; 53 | break; 54 | case SSE_TXT: 55 | return TXT; 56 | break; 57 | case STARLING: 58 | return XML; 59 | break; 60 | case COCOS2D: 61 | return PLIST; 62 | break; 63 | } 64 | return null; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/org/zengrong/display/spritesheet/SpriteSheetType.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong 4 | // 创建时间:2011-04-11 5 | // 修改时间:2012-10-15 6 | //////////////////////////////////////////////////////////////////////////////// 7 | package org.zengrong.display.spritesheet 8 | { 9 | /** 10 | * 定义SpriteSheet的类型 11 | * @author zrong 12 | */ 13 | public class SpriteSheetType 14 | { 15 | /** 16 | * 正常的png文件,没有加入过任何内容,metaData数据需要另行提供 17 | */ 18 | public static const PNG_IMAGE:String = 'SSPI'; 19 | 20 | /** 21 | * 正常的jpg文件,没有加入过任何内容,metaData数据需要另行提供 22 | */ 23 | public static const JPG_IMAGE:String = 'SSJI'; 24 | 25 | /** 26 | * 正常的JPEG-XR文件,metaData数据需要另行提供 27 | */ 28 | public static const JPG_XR_IMAGE:String = "SSXI"; 29 | 30 | /** 31 | * 在文件头中加入了元数据的PNG文件 32 | */ 33 | public static const PNG_BINARY:String = 'SSPB'; 34 | 35 | /** 36 | * 在文件头中加入了元数据的JPG文件 37 | */ 38 | public static const JPG_BINARY:String = 'SSJB'; 39 | 40 | /** 41 | * 在文件头中加入了元数据的JPEG-XR文件 42 | */ 43 | public static const JPG_XR_BINARY:String = "SSXB"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/org/zengrong/events/InfoEvent.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong 4 | // 创建时间:忘了 5 | // 最后修改:2012-03-06 6 | //////////////////////////////////////////////////////////////////////////////// 7 | package org.zengrong.events 8 | { 9 | import flash.events.Event; 10 | 11 | public class InfoEvent extends Event 12 | { 13 | public var info:*; 14 | 15 | public function InfoEvent($type:String, $info:*=null, $bubbles:Boolean=false, $cancelable:Boolean=false) 16 | { 17 | super($type, $bubbles, $cancelable); 18 | info = $info; 19 | } 20 | 21 | override public function clone():Event 22 | { 23 | return new InfoEvent(type, info, bubbles, cancelable); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/org/zengrong/events/TouchAndGestureEvent.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong(zrongzrong@gmail.com) 4 | // 创建时间:2012-6-14 5 | // 最后修改:2012-6-14 6 | //////////////////////////////////////////////////////////////////////////////// 7 | package org.zengrong.events 8 | { 9 | import flash.events.Event; 10 | 11 | /** 12 | * 实现手势事件 13 | * @author zrong 14 | */ 15 | public class TouchAndGestureEvent extends Event 16 | { 17 | /** 18 | * 手势事件,实现“抛”动作的侦测 19 | * @eventType gestureThrow 20 | */ 21 | public static const GESTURE_THROW:String = 'gestureThrow'; 22 | 23 | /** 24 | * 开始检测手势,当按下的时候发送此事件 25 | * @eventType gestureCheckStarting 26 | */ 27 | public static const GESTURE_CHECK_STARTING:String = 'gestureCheckStarting'; 28 | 29 | /** 30 | * 开始检测手势,当超过了移动误差值之后发送此事件。此事件一定在GESTURE_STARTING_CHECK之后发送 31 | * @eventType gestureCheckStart 32 | */ 33 | public static const GESTURE_CHECK_START:String = "gestureCheckStart"; 34 | 35 | /** 36 | * 停止检测手势 37 | * @eventType gestureCheckStop 38 | */ 39 | public static const GESTURE_CHECK_STOP:String = 'gestureCheckStop'; 40 | 41 | /** 42 | * 放开触摸的时候发送此事件 43 | * @eventType touchLeave 44 | */ 45 | public static const TOUCH_LEAVE:String = "touchLeave"; 46 | 47 | /** 48 | * 触摸并移动 49 | * @eventType touchMove 50 | */ 51 | public static const TOUCH_MOVE:String = 'touchMove'; 52 | 53 | /** 54 | * 移动超限 55 | * @eventType beyond 56 | */ 57 | public static const BEYOND:String = 'beyond'; 58 | 59 | public function TouchAndGestureEvent($type:String, $velX:Number=NaN, $velY:Number=NaN, $bubbles:Boolean=false, $cancelable:Boolean=false) 60 | { 61 | super($type, $bubbles, $cancelable); 62 | velX = $velX; 63 | velY = $velY; 64 | } 65 | 66 | /** 67 | * 负数代表向左移动,正数为向右 68 | */ 69 | public var velX:Number; 70 | 71 | /** 72 | * 负数代表向上移动,正数代表向下 73 | */ 74 | public var velY:Number; 75 | 76 | 77 | override public function clone():Event 78 | { 79 | return new TouchAndGestureEvent(type, velX, velY, bubbles, cancelable); 80 | } 81 | 82 | override public function toString():String 83 | { 84 | return 'org.zengrong.events.GestureEvent:{' + 85 | 'type:'+type+ 86 | ',bubble:'+bubbles+ 87 | ',cancelable:'+cancelable+ 88 | ',velX:'+velX+ 89 | ',velY:'+velY +'}'; 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /src/org/zengrong/file/FileEnding.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.file 2 | { 3 | /** 4 | * 保存不同平台的换行符,的枚举 5 | * @author zrong 6 | * 创建日期:2012-02-21 7 | */ 8 | public class FileEnding 9 | { 10 | /** 11 | * 微软操作系统的换行符 12 | */ 13 | public static const DOS:String = '\r\n'; 14 | 15 | /** 16 | * 苹果操作系统的换行符 17 | */ 18 | public static const MAC:String = '\r'; 19 | 20 | /** 21 | * 类Unix系统的换行符 22 | */ 23 | public static const UNIX:String = '\n'; 24 | } 25 | } -------------------------------------------------------------------------------- /src/org/zengrong/flex/components/ColoredDataGrid.as: -------------------------------------------------------------------------------- 1 | /** 2 | * 继承DataGrid,为其添加行背景色功能 3 | */ 4 | package org.zengrong.flex.components 5 | { 6 | import mx.controls.DataGrid; 7 | import flash.display.Sprite; 8 | import mx.collections.ArrayCollection; 9 | 10 | public class ColoredDataGrid extends DataGrid 11 | { 12 | [Bindable] 13 | public var rowColorFunction:Function; 14 | 15 | public function ColoredDataGrid() 16 | { 17 | super(); 18 | } 19 | 20 | override protected function drawRowBackground($s:Sprite, $rowIndex:int, $y:Number, $height:Number, $color:uint, $dataIndex:int):void 21 | { 22 | if( rowColorFunction != null && dataProvider != null) { 23 | var _dp:ArrayCollection = dataProvider as ArrayCollection; 24 | var _item:Object; 25 | if( $dataIndex < _dp.length ) 26 | { 27 | _item = _dp.getItemAt($dataIndex); 28 | $color = rowColorFunction( _item, $rowIndex, $dataIndex, $color ); 29 | } 30 | } 31 | super.drawRowBackground($s, $rowIndex, $y, $height, $color, $dataIndex); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/org/zengrong/flex/components/ImageButton.mxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/org/zengrong/flex/layouts/SpriteSheetBitmapFillMode.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.flex.layouts 2 | { 3 | /** 4 | * SpriteSheetBitmapFillMode 类定义了调整SpriteSheet中的图像块大小模式的一个枚举,这些模式确定 SpriteSheetGroup 如何填充由布局系统指定的 SpriteSheetBitmapImage 图像块。 5 | * @author zrong 6 | * @see org.zengrong.flex.layouts.SpriteSheetCell 7 | * @see org.zengrong.flex.components.SpriteSheetGoup 8 | * 创建时间:2012-02-06 9 | */ 10 | public class SpriteSheetBitmapFillMode 11 | { 12 | /** 13 | * 在x方向重复位图 14 | */ 15 | public static const REPEAT_X:String = 'repeatX'; 16 | 17 | /** 18 | * 在y方向重复位图 19 | */ 20 | public static const REPEAT_Y:String = 'repeatY'; 21 | 22 | /** 23 | * 同时在x方向和y方向重复位图 24 | */ 25 | public static const REPEAT_XY:String = 'repeatXY'; 26 | } 27 | } -------------------------------------------------------------------------------- /src/org/zengrong/flex/layouts/SpriteSheetCellVO.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.flex.layouts 2 | { 3 | import org.zengrong.flex.primitives.SpriteSheetBitmapImage; 4 | /** 5 | * 暂存在SpriteSheetLayout布局过程中的临时ValueObject 6 | * @author zrong 7 | * 创建日期:2012-02-06 8 | */ 9 | public class SpriteSheetCellVO 10 | { 11 | 12 | public function SpriteSheetCellVO() 13 | { 14 | } 15 | 16 | public var bmp:SpriteSheetBitmapImage; 17 | public var originalW:Number; 18 | public var originalH:Number; 19 | public var measureW:Number; 20 | public var measureH:Number; 21 | public var measureX:int; 22 | public var measureY:int; 23 | 24 | /** 25 | * 显示的指定X 26 | */ 27 | public var explicitX:Number; 28 | 29 | /** 30 | * 显示的指定Y 31 | */ 32 | public var explicitY:Number; 33 | 34 | public var fillMode:String; 35 | 36 | public var rowIndex:int = -1; 37 | } 38 | } -------------------------------------------------------------------------------- /src/org/zengrong/flex/layouts/SpriteSheetLayoutBase.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.flex.layouts 2 | { 3 | import flash.geom.Rectangle; 4 | 5 | import mx.core.ILayoutElement; 6 | 7 | import org.zengrong.flex.layouts.SpriteSheetCellVO; 8 | import org.zengrong.flex.primitives.SpriteSheetBitmapImage; 9 | 10 | import spark.components.supportClasses.GroupBase; 11 | import spark.layouts.supportClasses.LayoutBase; 12 | import spark.primitives.BitmapImage; 13 | 14 | public class SpriteSheetLayoutBase extends LayoutBase 15 | { 16 | public function SpriteSheetLayoutBase() 17 | { 18 | super(); 19 | } 20 | 21 | protected var _cells:Array; 22 | 23 | public function get cells():Array 24 | { 25 | return _cells; 26 | } 27 | 28 | public function set cells($value:Array):void 29 | { 30 | _cells = $value; 31 | } 32 | 33 | override public function get useVirtualLayout():Boolean 34 | { 35 | return false; 36 | } 37 | 38 | /** 39 | * 不支持虚拟化 40 | */ 41 | override public function set useVirtualLayout(value:Boolean):void 42 | { 43 | 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/org/zengrong/flex/primitives/SpriteSheetBitmapImage.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.flex.primitives 2 | { 3 | import org.zengrong.flex.layouts.SpriteSheetCell; 4 | 5 | import spark.primitives.BitmapImage; 6 | 7 | public class SpriteSheetBitmapImage extends BitmapImage 8 | { 9 | public function SpriteSheetBitmapImage() 10 | { 11 | super(); 12 | } 13 | 14 | private var _cell:SpriteSheetCell; 15 | 16 | public function get cell():SpriteSheetCell 17 | { 18 | return _cell; 19 | } 20 | 21 | public function set cell($value:SpriteSheetCell):void 22 | { 23 | _cell = $value; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/org/zengrong/flex/utils/Dialog.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.flex.utils 2 | { 3 | import flash.display.Sprite; 4 | 5 | import mx.controls.Alert; 6 | import mx.core.FlexGlobals; 7 | import mx.events.CloseEvent; 8 | 9 | public class Dialog 10 | { 11 | public static function alert($info:String, $title:String='', $parent:Sprite=null):void 12 | { 13 | var __parent:Sprite = $parent ? $parent : FlexGlobals.topLevelApplication as Sprite; 14 | Alert.show($info, $title, 4, __parent); 15 | } 16 | 17 | /** 18 | * 弹出confirm确认对话框,根据用户的交互返回是否确认布尔值 19 | * @param $s 要显示的信息 20 | * @param $closeFun 关闭确认对话框时调用的函数 21 | */ 22 | public static function confirm($s:String, $closeFun:Function, $title:String='', $parent:Sprite=null):void 23 | { 24 | var __fun:Function = function(evt:CloseEvent):void 25 | { 26 | $closeFun(evt.detail == Alert.YES); 27 | } 28 | var __parent:Sprite = $parent ? $parent : FlexGlobals.topLevelApplication as Sprite; 29 | Alert.show($s, $title, Alert.YES|Alert.NO, __parent, __fun); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/org/zengrong/flex/utils/JS.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.flex.utils 2 | { 3 | import flash.display.Sprite; 4 | import flash.external.ExternalInterface; 5 | 6 | import mx.controls.Alert; 7 | import mx.core.FlexGlobals; 8 | import mx.events.CloseEvent; 9 | 10 | // 11 | 12 | public class JS 13 | { 14 | public static function alert($info:String, $title:String=''):void 15 | { 16 | if(ExternalInterface.available) 17 | { 18 | try 19 | { 20 | ExternalInterface.call('alert', $info); 21 | } 22 | catch(err:Error) 23 | { 24 | trace(err); 25 | Alert.show(err.toString(), '調用容器失敗'); 26 | } 27 | } 28 | else 29 | { 30 | Alert.show($info, $title, 4, FlexGlobals.topLevelApplication as Sprite); 31 | } 32 | } 33 | 34 | public static function close($error:String='窗口關閉'):void 35 | { 36 | if(ExternalInterface.available) 37 | { 38 | try 39 | { 40 | ExternalInterface.call('window.close'); 41 | } 42 | catch(err:Error) 43 | { 44 | trace(err); 45 | Alert.show(err.toString(), '調用容器失敗'); 46 | } 47 | } 48 | else 49 | { 50 | Alert.show($error); 51 | } 52 | } 53 | 54 | /** 55 | * 弹出JavaScript confirm确认对话框,根据用户的交互返回是否确认布尔值 56 | * @param $s 要显示的信息 57 | * @param $closeFun 关闭确认对话框时调用的函数 58 | */ 59 | public static function confirm($s:String, $closeFun:Function, $title:String=''):void 60 | { 61 | var __fun:Function = function(evt:CloseEvent):void 62 | { 63 | $closeFun(evt.detail == Alert.YES); 64 | } 65 | if(ExternalInterface.available) 66 | { 67 | try 68 | { 69 | $closeFun(ExternalInterface.call('confirm', $s)); 70 | } 71 | catch(err:Error) 72 | { 73 | trace(err); 74 | Alert.show(err.toString(), '調用容器失敗'); 75 | } 76 | } 77 | else 78 | { 79 | Alert.show($s, $title, Alert.YES|Alert.NO, FlexGlobals.topLevelApplication as Sprite, __fun); 80 | } 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /src/org/zengrong/logging/FirebugLogger.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.logging 2 | { 3 | public class FirebugLogger 4 | { 5 | public function FirebugLogger() 6 | { 7 | } 8 | 9 | public function log(...parameters):void 10 | { 11 | Firebug.log.apply(null, parameters); 12 | } 13 | 14 | public function debug(...parameters):void 15 | { 16 | Firebug.debug.apply(null, parameters); 17 | } 18 | 19 | public function error(...parameters):void 20 | { 21 | Firebug.error.apply(null, parameters); 22 | } 23 | 24 | public function fatal(...parameters):void 25 | { 26 | Firebug.fatal.apply(null, parameters); 27 | } 28 | 29 | public function info(...parameters):void 30 | { 31 | Firebug.info.apply(null, parameters); 32 | } 33 | 34 | public function warn(...parameters):void 35 | { 36 | Firebug.info.apply(null, parameters); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/org/zengrong/media/NetConnectionInfoCode.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // zengrong.net 4 | // 创建者: zrong 5 | // 最后更新时间:2010-12-06 6 | // 7 | //////////////////////////////////////////////////////////////////////////////// 8 | package org.zengrong.media 9 | { 10 | /** 11 | * 保存NetConnection连接时返回的字符串,这样在比对连接状态的时候就不用输入这些字符串了。 12 | * @author zrong 13 | */ 14 | public class NetConnectionInfoCode 15 | { 16 | //常用的NC连接错误信息 17 | public static const SUCCESS:String = "NetConnection.Connect.Success"; 18 | public static const FAILED:String = "NetConnection.Connect.Failed"; 19 | public static const REJECTED:String = "NetConnection.Connect.Rejected"; 20 | public static const CLOSED:String = "NetConnection.Connect.Closed"; 21 | public static const APP_SHUTDOWN:String = "NetConnection.Connect.AppShutdown"; 22 | 23 | public static const CALL_SUCCESS:String = "NetConnection.Call.Success"; 24 | public static const CALL_FAILED:String = "NetConnection.Call.Failed"; 25 | public static const ADMIN_FAILED:String = "NetConnection.Admin.CommandFailed"; 26 | public static const CALL_BAD:String = "NetConnection.Call.BadValue"; 27 | } 28 | } -------------------------------------------------------------------------------- /src/org/zengrong/media/NetStreamInfoCode.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // zengrong.net 4 | // 创建者: zrong 5 | // 最后更新时间:2010-12-06 6 | // 7 | //////////////////////////////////////////////////////////////////////////////// 8 | package org.zengrong.media 9 | { 10 | /** 11 | * 保存NetStream连接时返回的字符串,这样在比对连接状态的时候就不用输入这些字符串了。 12 | * @author zrong 13 | */ 14 | public class NetStreamInfoCode 15 | { 16 | //常用的NS连接错误信息 17 | public static const PUB_START:String = "NetStream.Publish.Start"; 18 | public static const UNPUB_SUCCESS:String = "NetStream.Unpublish.Success"; 19 | public static const PUB_BADNAME:String = "NetStream.Publish.BadName"; 20 | public static const PLAY_START:String = "NetStream.Play.Start"; 21 | public static const PLAY_STOP:String = "NetStream.Play.Stop"; 22 | public static const PLAY_PUB_NOTIFY:String = "NetStream.Play.PublishNotify"; 23 | public static const PLAY_UNPUB_NOTIFY:String = "NetStream.Play.UnpublishNotify"; 24 | public static const PLAY_INSUF_BW:String = "NetStream.Play.InsufficientBW"; 25 | 26 | //下面3个play相关的code来源于NetStream的client的onPlayStatus处理器 27 | public static const PLAY_COMPLETE:String = 'NetStream.Play.Complete'; //流的播放已经结束 28 | public static const PLAY_SWITCH:String = 'NetStream.Play.Switch'; //流的订阅者正在从播放列表中的一个流切换到另一个流 29 | public static const PLAY_TRANSITION:String = 'NetStream.Play.TransitionComplete'; //应用流比特率切换之后,订户将切换到新的流 30 | 31 | public static const BUFFER_EMPTY:String = "NetStream.Buffer.Empty"; 32 | public static const BUFFER_FULL:String = "NetStream.Buffer.Full"; 33 | public static const FAILED:String = "NetStream.Failed"; 34 | } 35 | } -------------------------------------------------------------------------------- /src/org/zengrong/media/cm/CMEvent.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong 4 | // 最后更新时间:2011-02-27 5 | //////////////////////////////////////////////////////////////////////////////// 6 | package org.zengrong.media.cm 7 | { 8 | import flash.events.Event; 9 | import flash.media.Camera; 10 | import flash.media.Microphone; 11 | 12 | /** 13 | * 检测摄像头和麦克风的事件 14 | * @author zrong 15 | */ 16 | public class CMEvent extends Event 17 | { 18 | /** 19 | * 摄像头禁用 20 | */ 21 | public static const CAMERA_MUTED:String = "cameraMuted"; 22 | 23 | /** 24 | * 摄像头启用 25 | */ 26 | public static const CAMERA_UN_MUTED:String = "cameraUnMuted"; 27 | 28 | /** 29 | * 多个摄像头 30 | */ 31 | public static const MULTI_CAMERA:String = "multiCamera"; 32 | 33 | /** 34 | * 麦克风禁用 35 | */ 36 | public static const MICROPHONE_MUTED:String = "microphoneMuted"; 37 | 38 | /** 39 | * 麦克风启用 40 | */ 41 | public static const MICROPHONE_UN_MUTED:String = "microphoneUnMuted"; 42 | 43 | /** 44 | * 没有摄像头 45 | */ 46 | public static const NO_CAMERA:String = "noCamera"; 47 | 48 | /** 49 | * 没有麦克风 50 | */ 51 | public static const NO_MICROPHONE:String = "noMicrophone"; 52 | 53 | /** 54 | * 摄像头可用,这个事件只会在第一次检测摄像头的时候发生一次 55 | */ 56 | public static const CAMERA_AVAILABLE:String = "cameraAvailable"; 57 | 58 | /** 59 | * 麦克风可用,这个事件只会在第一次检测麦克风的时候发生一次 60 | */ 61 | public static const MICROPHONE_AVAILABLE:String = "microphoneAvailable"; 62 | 63 | /** 64 | * 在摄像头中的图像开始运动时调度 65 | */ 66 | public static const ACTIVITY_START:String = 'activityStart'; 67 | 68 | /** 69 | *在摄像头中的图像结束运动时调度 70 | */ 71 | public static const ACTIVITY_STOP:String = 'activityStop'; 72 | 73 | public function CMEvent($type:String, $result:CMVO=null, $bubbles:Boolean=false, $cancelable:Boolean=true) 74 | { 75 | super($type, $bubbles, $cancelable); 76 | result = $result; 77 | } 78 | 79 | public var result:CMVO; 80 | 81 | override public function clone():Event 82 | { 83 | return new CMEvent(type, result, bubbles, cancelable); 84 | } 85 | 86 | override public function toString():String 87 | { 88 | return 'org.zengrong.media.cm:CMEvent {' + 89 | 'type=' + type + ',' + 90 | 'result=' + result + '}'; 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /src/org/zengrong/media/cm/CMVO.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong 4 | // 最后更新时间:日期 5 | //////////////////////////////////////////////////////////////////////////////// 6 | package org.zengrong.media.cm 7 | { 8 | import flash.media.Camera; 9 | import flash.media.Microphone; 10 | 11 | /** 12 | * 包含 13 | * @author zrong 14 | */ 15 | public class CMVO 16 | { 17 | public function CMVO($camOrMic:* = null, $camOrMicNames:Array = null, $isManual:Boolean = false) 18 | { 19 | if($camOrMic is Camera) 20 | { 21 | cam = $camOrMic; 22 | mic = null; 23 | } 24 | else if($camOrMic is Microphone) 25 | { 26 | mic = $camOrMic; 27 | cam = null; 28 | } 29 | else 30 | { 31 | cam = null; 32 | mic = null; 33 | } 34 | names = $camOrMicNames; 35 | manual = $isManual; 36 | } 37 | 38 | /** 39 | * 摄像头实例 40 | */ 41 | public var cam:Camera; 42 | /** 43 | * 麦克风实例 44 | */ 45 | public var mic:Microphone; 46 | /** 47 | * 麦克风或者摄像头的名称数组 48 | */ 49 | public var names:Array; 50 | /** 51 | * 是否是手动启用或禁用摄像头 52 | */ 53 | public var manual:Boolean; 54 | 55 | public function toString():String 56 | { 57 | return 'org.zengrong.media.cm:CMVO {' + 58 | 'cam=' + cam +',' + 59 | 'mic=' + mic + ',' + 60 | 'names=' + names + ',' + 61 | 'manual=' + manual + '}'; 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /src/org/zengrong/net/HTTPLoaderDoneVO.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.net 2 | { 3 | /** 4 | * HTTPLoader调用成功返回的VO 5 | * @author zrong (http://zengrong.net) 6 | * 创建日期:2012-12-4 7 | */ 8 | public class HTTPLoaderDoneVO extends HTTPLoaderVO 9 | { 10 | public function HTTPLoaderDoneVO() 11 | { 12 | } 13 | 14 | /** 15 | * 调用成功后HTTP服务器返回的数据 16 | */ 17 | public var resultData:Object; 18 | } 19 | } -------------------------------------------------------------------------------- /src/org/zengrong/net/HTTPLoaderErrorVO.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.net 2 | { 3 | import flash.events.ErrorEvent; 4 | 5 | /** 6 | * HTTPLoader调用失败返回的VO 7 | * @author zrong (http://zengrong.net) 8 | * 创建日期:2012-12-4 9 | * 修改日期:2013-02-07 10 | */ 11 | public class HTTPLoaderErrorVO extends HTTPLoaderVO 12 | { 13 | public function HTTPLoaderErrorVO() 14 | { 15 | } 16 | 17 | /** 18 | * 错误的类型 19 | */ 20 | public var type:String; 21 | 22 | /** 23 | * 错误消息 24 | */ 25 | public var message:String; 26 | 27 | /** 28 | * 报错时候的error事件 29 | */ 30 | public var errorEvent:ErrorEvent; 31 | } 32 | } -------------------------------------------------------------------------------- /src/org/zengrong/net/HTTPLoaderVO.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.net 2 | { 3 | /** 4 | * HTTPLoader返回的数据的基类 5 | * @author zrong (http://zengrong.net) 6 | * 创建日期:2012-12-4 7 | * 修改日期:2013-02-07 8 | */ 9 | public class HTTPLoaderVO 10 | { 11 | public function HTTPLoaderVO() 12 | { 13 | } 14 | 15 | /** 16 | * 提交的地址 17 | */ 18 | public var url:String; 19 | 20 | /** 21 | * 提交的时候要求返回的数据
22 | * 一般可以把提交的参数放在这个对象中,这样在提交出错的时候,可以使用这些数据重复提交。 23 | */ 24 | public var returnData:Object; 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /src/org/zengrong/net/ILoader.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong 4 | // 创建时间:2011-04-23 5 | //////////////////////////////////////////////////////////////////////////////// 6 | package org.zengrong.net 7 | { 8 | /** 9 | * 所有的Loader类型的类都必须实现这个接口 10 | * @author zrong 11 | */ 12 | public interface ILoader 13 | { 14 | /** 15 | * 返回当前载入的文件类型 16 | * */ 17 | function get type():String; 18 | 19 | /** 20 | * 返回当前是否正在载入 21 | */ 22 | function get loading():Boolean; 23 | 24 | function destroy():void; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/org/zengrong/rpc/Remoting.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.rpc 2 | { 3 | import flash.events.Event; 4 | import flash.events.IOErrorEvent; 5 | import flash.events.NetStatusEvent; 6 | import flash.events.SecurityErrorEvent; 7 | import flash.net.NetConnection; 8 | import flash.net.Responder; 9 | 10 | public class Remoting extends NetConnection 11 | { 12 | public static const CONNECT_ERROR:String = 'connectError'; 13 | protected var gateway:String; 14 | protected var service:String; 15 | 16 | public function Remoting($gateway:String, $service:String) 17 | { 18 | super(); 19 | gateway = $gateway; 20 | service = $service; 21 | this.addEventListener(NetStatusEvent.NET_STATUS, _netStatusHandler); 22 | this.addEventListener(IOErrorEvent.IO_ERROR, _connError); 23 | this.addEventListener(SecurityErrorEvent.SECURITY_ERROR, _connError); 24 | this.connect(gateway); 25 | trace('remoting connect',$gateway, $service); 26 | } 27 | 28 | private function _netStatusHandler(evt:NetStatusEvent):void 29 | { 30 | trace('remoting状态:', evt.info.code); 31 | switch(evt.info.code) { 32 | case "NetConnection.Connect.Failed": 33 | dispatchEvent(new Event(CONNECT_ERROR)); 34 | break; 35 | } 36 | } 37 | 38 | private function _connError(evt:*):void 39 | { 40 | dispatchEvent(new Event(CONNECT_ERROR)); 41 | } 42 | 43 | override public function call($methodName:String, $responder:Responder, ...$arguments):void { 44 | var __operationPath:String = service + "." + $methodName; 45 | var __callArgs:Array = [__operationPath, $responder]; 46 | for (var i:uint = 0; i < $arguments.length; i++) { 47 | __callArgs.push($arguments[i]); 48 | } 49 | super.call.apply(null, __callArgs); 50 | } 51 | 52 | override public function toString():String 53 | { 54 | return "org.zengrong.rpc.Remoting {" + 55 | ' gateway:' + gateway + 56 | ', service:' + service +'}'; 57 | } 58 | 59 | } 60 | } -------------------------------------------------------------------------------- /src/org/zengrong/rpc/ResultEvent.as: -------------------------------------------------------------------------------- 1 | //******************************************************************************* 2 | // Copyright (c) 2006 Patterson Consulting, Inc 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // * Redistributions of source code must retain all references to Patterson 9 | // Consulting, Danny Patterson, com.dannypatterson and dannypatterson.com. 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the Patterson Consulting nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY 20 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | //******************************************************************************* 30 | 31 | 32 | package org.zengrong.rpc { 33 | 34 | import flash.events.Event; 35 | 36 | /** 37 | * @author Danny Patterson 38 | * @version 1.0.0 2006-07-03 39 | */ 40 | public class ResultEvent extends Event { 41 | 42 | public static const RESULT:String = "result_event"; 43 | public var result:Object; 44 | 45 | 46 | public function ResultEvent(type:String, bubbles:Boolean, cancelable:Boolean, result:Object) { 47 | this.result = result; 48 | super(type, bubbles, cancelable); 49 | } 50 | 51 | 52 | public override function toString():String { 53 | return "remoting.service.ResultEvent"; 54 | } 55 | 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/org/zengrong/text/FTEFactory.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // youxi.com 3 | // 创建者: zrong 4 | // 创建时间:2011-02-25 5 | //////////////////////////////////////////////////////////////////////////////// 6 | package org.zengrong.text 7 | { 8 | import flash.text.engine.ElementFormat; 9 | import flash.text.engine.FontDescription; 10 | import flash.text.engine.TextBaseline; 11 | import flash.text.engine.TextBlock; 12 | import flash.text.engine.TextElement; 13 | import flash.text.engine.TextLine; 14 | 15 | /** 16 | * 关于FTE的一些创建工厂,因为直接用FTE要建很多对象,很麻烦。 17 | * @author zrong 18 | */ 19 | public class FTEFactory 20 | { 21 | /** 22 | * 创建一个单行的TextLine 23 | * @param $str 文本内容 24 | * @param $width 文本宽度 25 | * @return 单行的TextLine 26 | */ 27 | public static function createSingleTextLine($str:String, $width:Number, $color:uint=0x000000, $size:int=12, $font:FontDescription=null):TextLine 28 | { 29 | if(!$font) 30 | $font = new FontDescription('Microsoft YaHei', 'bold'); 31 | var __ef:ElementFormat = new ElementFormat($font); 32 | __ef.color = $color; 33 | __ef.fontSize = $size; 34 | var __tb:TextBlock = new TextBlock(new TextElement($str, __ef)); 35 | return __tb.createTextLine(null, $width); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/org/zengrong/ui/ClassButton.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong 4 | // 创建时间:2011-01-02 5 | // 修改时间:2011-10-12 6 | // 说明:本组件参照Keith Peters的Minimalcomps组件写成,修改、使用或继承Minimalcal源码 7 | //////////////////////////////////////////////////////////////////////////////// 8 | package org.zengrong.ui 9 | { 10 | import flash.display.DisplayObject; 11 | import flash.display.DisplayObjectContainer; 12 | 13 | 14 | /** 15 | * 根据提供的Class生成按钮。提供的Class必须是显示对象的Class,例如嵌入的图像文件、MovieClip等等。 16 | * @author zrong 17 | */ 18 | public class ClassButton extends DisplayObjectButtonBase 19 | { 20 | public function ClassButton($class:Class, $parent:DisplayObjectContainer = null, $xpos:Number = 0, $ypos:Number = 0, $defaultHandler:Function = null) 21 | { 22 | _upState = DisplayObject(new $class); 23 | _colorless = true; 24 | super($parent, $xpos, $ypos, $defaultHandler); 25 | setSize(_upState.width, _upState.height); 26 | } 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/org/zengrong/ui/Style.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // zengrong.net 4 | // 修改:zrong 5 | // 说明:本组件参照Keith Peters的Minimalcomps组件写成,修改、使用或继承Minimalcal源码 6 | // 修改列表: 7 | // 2011-01-02 加入静态的COLORLESS_FILTER变量 8 | // 9 | //////////////////////////////////////////////////////////////////////////////// 10 | /** 11 | * Style.as 12 | * Keith Peters 13 | * version 0.9.7 14 | * 15 | * A collection of style variables used by the components. 16 | * If you want to customize the colors of your components, change these values BEFORE instantiating any components. 17 | * 18 | * Copyright (c) 2010 Keith Peters 19 | * 20 | * Permission is hereby granted, free of charge, to any person obtaining a copy 21 | * of this software and associated documentation files (the "Software"), to deal 22 | * in the Software without restriction, including without limitation the rights 23 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 24 | * copies of the Software, and to permit persons to whom the Software is 25 | * furnished to do so, subject to the following conditions: 26 | * 27 | * The above copyright notice and this permission notice shall be included in 28 | * all copies or substantial portions of the Software. 29 | * 30 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 36 | * THE SOFTWARE. 37 | */ 38 | 39 | package org.zengrong.ui 40 | { 41 | import flash.filters.ColorMatrixFilter; 42 | import org.zengrong.utils.ColorMatrix; 43 | 44 | public class Style 45 | { 46 | public static var BACKGROUND:uint = 0xCCCCCC; 47 | public static var BUTTON_FACE:uint = 0xFFFFFF; 48 | public static var INPUT_TEXT:uint = 0x333333; 49 | public static var LABEL_TEXT:uint = 0x666666; 50 | public static var DROPSHADOW:uint = 0x000000; 51 | public static var PANEL:uint = 0xF3F3F3; 52 | public static var PROGRESS_BAR:uint = 0xFFFFFF; 53 | public static var COLORLESS_FILTER:ColorMatrixFilter = new ColorMatrixFilter(ColorMatrix.COLORLESS); 54 | 55 | public static var embedFonts:Boolean = false; 56 | public static var fontName:String = "simsun"; 57 | public static var fontSize:Number = 12; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/org/zengrong/ui/UI.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.ui 2 | { 3 | import flash.display.Sprite; 4 | /** 5 | * 所有UI组件的基类 6 | */ 7 | public class UI extends Sprite 8 | { 9 | public function UI() 10 | { 11 | } 12 | 13 | protected var _width:Number; 14 | protected var _height:Number; 15 | protected var _enabled:Boolean; 16 | 17 | protected function init():void 18 | { 19 | } 20 | 21 | protected function addChildren():void 22 | { 23 | } 24 | 25 | protected function draw():void 26 | { 27 | } 28 | 29 | override public function get width():Number 30 | { 31 | return _width; 32 | } 33 | 34 | override public function set width($w:Number):void 35 | { 36 | _width = $w; 37 | draw(); 38 | } 39 | override public function get height():Number 40 | { 41 | return _height; 42 | } 43 | 44 | override public function set height($h:Number):void 45 | { 46 | _height = $h; 47 | draw(); 48 | } 49 | 50 | public function set enabled($en:Boolean):void 51 | { 52 | _enabled = $en; 53 | mouseEnabled = mouseChildren = _enabled; 54 | tabEnabled = $en; 55 | } 56 | 57 | public function get enabled():Boolean 58 | { 59 | return _enabled; 60 | } 61 | 62 | public function setSize($width:int, $height:int): void 63 | { 64 | width = $width; 65 | height = $height; 66 | } 67 | 68 | public function move($x:int, $y:int):void 69 | { 70 | x = $x; 71 | y = $y; 72 | } 73 | 74 | public function destroy():void 75 | { 76 | } 77 | 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/org/zengrong/utils/ByteSize.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.utils 2 | { 3 | /** 4 | * 保存字节的常用大小 5 | * @author zrong 6 | * 创建日期:2012-6-17 7 | */ 8 | public class ByteSize 9 | { 10 | public static const KB:uint = 1024; 11 | public static const MB:uint = 1048576; 12 | public static const GB:uint = 1073741824; 13 | } 14 | } -------------------------------------------------------------------------------- /src/org/zengrong/utils/ColorMatrix.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // zengrong.net 4 | // 创建者: zrong 5 | // 最后更新时间:2010-12-21 6 | // 7 | //////////////////////////////////////////////////////////////////////////////// 8 | package org.zengrong.utils 9 | { 10 | /** 11 | * 保存一些常用的颜色矩阵信息 12 | * @author zrong 13 | * 14 | */ 15 | public class ColorMatrix 16 | { 17 | /** 18 | * 无色的颜色矩阵 19 | */ 20 | public static const COLORLESS:Array = [0.3086,0.6094,0.082,0,-25,0.3086,0.6094,0.082,0,-25,0.3086,0.6094,0.082,0,-25,0,0,0,1,0]; 21 | } 22 | } -------------------------------------------------------------------------------- /src/org/zengrong/utils/GC.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong(zrongzrong@gmail.com) 4 | // 创建时间:2011-8-10 5 | //////////////////////////////////////////////////////////////////////////////// 6 | 7 | package org.zengrong.utils 8 | { 9 | import flash.net.LocalConnection; 10 | 11 | /** 12 | * 执行强制垃圾回收 13 | * 每次执行约耗费200ms,若引用关系复杂则更甚,慎用慎用 14 | * @author zrong 15 | */ 16 | public function GC():void 17 | { 18 | //连续两次连接同一地址会抛出异常,Flash Player在遇到异常的时候会强制进行垃圾回收 19 | //使用LocalConnection的原因是这个操作很不常用,不易发生冲突 20 | start(); start(); 21 | function start ():void { try { new LocalConnection().connect('GC'); } catch (e:Error) {} } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/org/zengrong/utils/ImageDecoder.as: -------------------------------------------------------------------------------- 1 | package org.zengrong.utils 2 | { 3 | import flash.display.Bitmap; 4 | import flash.display.BitmapData; 5 | import flash.display.DisplayObject; 6 | import flash.display.Loader; 7 | import flash.events.Event; 8 | import flash.geom.Rectangle; 9 | import flash.utils.ByteArray; 10 | 11 | public class ImageDecoder 12 | { 13 | private var _loader:Loader = new Loader(); 14 | public var loading:Boolean; 15 | 16 | /** 17 | * 将载入的ByteArray转换成BitmapData。 18 | * @param $byte 图片文件的ByteArray 19 | * @param $callBack 图片文件载入完毕后的回调函数。 20 | */ 21 | public function ImageDecoder($byte:ByteArray, $callBack:Function) { 22 | loading = true; 23 | _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, 24 | function(evt:Event):void{ 25 | loading = false; 26 | $callBack.call(null, Bitmap(evt.target.content)); 27 | }); 28 | _loader.loadBytes($byte); 29 | } 30 | 31 | //将可视的UIComponent组件转换为ByteArray数组,我就是在UIComponent那里放了一个图片 32 | public static function BitmapDataToByteArray(target:DisplayObject):ByteArray 33 | { 34 | var imageWidth:uint = target.width; 35 | var imageHeight:uint = target.height; 36 | var srcBmp:BitmapData = new BitmapData( imageWidth, imageHeight ); 37 | //将组件读取为BitmapData对象,bitmagData的数据源 38 | srcBmp.draw( target ); 39 | //getPixels方法用于读取指定像素区域生成一个ByteArray,Rectangle是一个区域框,就是起始坐标 40 | var pixels:ByteArray = srcBmp.getPixels( new Rectangle(0,0,imageWidth,imageHeight) ); 41 | //下面俩行将数据源的高和宽一起存储到数组中,为翻转的时候提供高度和宽度 42 | pixels.writeShort(imageHeight); 43 | pixels.writeShort(imageWidth); 44 | return pixels; 45 | } 46 | 47 | //次方法的参数必须是像上面的ByteArray形式一样的,即需要对象的大小; 48 | //此方法返回的Bitmap可以直接赋值给Image的source属性 49 | public static function ByteArrayToBitmap(byArr:ByteArray):Bitmap 50 | { 51 | if(byArr==null){ 52 | return null; 53 | } 54 | //读取出存入时图片的高和宽,因为是最后存入的数据,所以需要到尾部读取 55 | var bmd:ByteArray= byArr; 56 | bmd.position=bmd.length-2; 57 | var imageWidth:int = bmd.readShort(); 58 | bmd.position=bmd.length-4; 59 | var imageHeight:int= bmd.readShort(); 60 | var copyBmp:BitmapData = new BitmapData( imageWidth, imageHeight, true ); 61 | //利用setPixel方法给图片中的每一个像素赋值,做逆操作 62 | //ByteArray数组从零开始存储一直到最后都是图片数据,因为读入时的高和宽都是一样的,所以当循环结束是正好读完 63 | bmd.position = 0; 64 | for( var i:uint=0; i$max) return $max; 31 | return $center; 32 | } 33 | 34 | /** 35 | * 获取一个范围内的随机整数 36 | * @param $max 随机数的最大值 37 | * @param $min 随机数的最小值 38 | */ 39 | public static function getRandom($max:int, $min:int=0):int 40 | { 41 | if($max === $min) 42 | return $max; 43 | return $min + Math.round(Math.random()*($max-$min)); 44 | } 45 | 46 | /** 47 | * 获取2的幂 48 | * 算法从这儿偷的:http://en.wikipedia.org/wiki/Power_of_two#Algorithm_to_find_the_next-highest_power_of_two 49 | */ 50 | public static function nextPowerOf2($k:int):int 51 | { 52 | $k--; 53 | for (var i:int = 1; i < 32 * 8; i <<= 1) 54 | $k = $k | $k >> i; 55 | return $k + 1; 56 | } 57 | 58 | /** 59 | * 二分查找,性能与Array和Vector原生的indexOf类似 60 | * http://www.nczonline.net/blog/tag/computer-science/ 61 | * Copyright 2009 Nicholas C. Zakas. All rights reserved. 62 | * MIT-Licensed, see source file 63 | * @param $items 被搜索的列表,必须是Array或者Vector 64 | * @param $value 被搜索的值,可以是任意类型,只要能使用==比较 65 | */ 66 | public static function binarySearch($items:*, $value:*):int 67 | { 68 | var __className:String = getQualifiedClassName($items); 69 | if(__className.search(/^(__AS3__.vec::Vector\.<\w+>)|(Array)$/)) 70 | throw TypeError("要使用二分查找,必须提供Array或者Vector!"); 71 | var __time:int=0; 72 | var __startIndex:int = 0; 73 | var __stopIndex:int = $items.length - 1; 74 | var __middle:int = int((__stopIndex + __startIndex)*.5); 75 | while($items[__middle] != $value && __startIndex < __stopIndex) 76 | { 77 | //调整查找范围 78 | if ($value < $items[__middle]) 79 | __stopIndex = __middle - 1; 80 | else if ($value > $items[__middle]) 81 | __startIndex = __middle + 1; 82 | //重新计算中项索引 83 | __middle = int((__stopIndex + __startIndex)*.5); 84 | __time++; 85 | } 86 | trace('次数:', __time); 87 | //确保返回正确的值 88 | return ($items[__middle] != $value) ? -1 : __middle; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/org/zengrong/utils/TimerUpdate.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong 4 | // 创建时间:2011-03-15 5 | ////////////////////////////////////////////////////////////////////////////////s 6 | package org.zengrong.utils 7 | { 8 | import flash.utils.*; 9 | 10 | /** 11 | * 处理增长和运动的时间 12 | * com.youxi.display.MoveableSprite使用这个类和Vec2D来处理运动 13 | * 因为间隔时间是绝对的,如果帧率降低,那么每帧运动的距离会增大,这样的运动不会因为帧率降低导致运动变慢 14 | * @author zrong 15 | * */ 16 | public class TimerUpdate 17 | { 18 | protected var _lastTime:uint = 0; //从程序启动到上一次调用update的时间,单位是毫秒 19 | protected var _curTime:uint = 0; //从程序启动到本次调用update后的时间,单位是毫秒 20 | protected var _delayTime:int = 0; //两次操作间的时间间隔,单位是毫秒 21 | public var speed:Number = 1.0; //全局速度系数 22 | 23 | /** 24 | * 最后一次调用update和上一次调用update间的时间间隔,单位是秒 25 | * */ 26 | public var delay:Number = 0; 27 | 28 | /** 29 | * 从游戏启动到最后一次调用update之间的时间流逝,单位是秒 30 | * */ 31 | public var elapsed:Number = 0; 32 | 33 | /** 34 | * 更新时间的流逝,更新elapsed和delayTime的值 35 | * @see #delayTime 36 | * @see #elapsed 37 | * */ 38 | public function update() : void 39 | { 40 | _curTime = getTimer(); 41 | _delayTime = _curTime - _lastTime; 42 | _lastTime = _curTime; 43 | //更新两个时间数字 44 | delay = _delayTime * speed * 0.001; 45 | elapsed = _curTime*0.001; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/org/zengrong/utils/checkPlatform.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong(zrongzrong@gmail.com) 4 | // 创建时间:2012-1-14 5 | //////////////////////////////////////////////////////////////////////////////// 6 | 7 | package org.zengrong.utils 8 | { 9 | import flash.system.Capabilities; 10 | /** 11 | * 检测Flash Player的平台 12 | * @param $platform 平台代码,值为WIN/MAC/LNX/AND或空字符串(代表不比较平台) 13 | */ 14 | public function checkPlatform($platform:String):Boolean 15 | { 16 | var __ver:String = Capabilities.version; 17 | var __split:Array = __ver.split(' '); 18 | return __split[0] == $platform; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/org/zengrong/utils/checkVersion.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // zengrong.net 3 | // 创建者: zrong(zrongzrong@gmail.com) 4 | // 创建时间:2012-1-14 5 | //////////////////////////////////////////////////////////////////////////////// 6 | 7 | package org.zengrong.utils 8 | { 9 | import flash.system.Capabilities; 10 | /** 11 | * 检测Flash Player的版本号 12 | * @param $major 主版本号,必须提供 13 | * @param $minor 次版本号,可选 14 | * @param $build 生成版本号,可选 15 | * @param $internal 内部生成版本号,可选 16 | * @return 若提供的版本号比当前版本号大,则返回1;若相等,则返回0;否则返回-1 17 | * @author zrong 18 | */ 19 | public function checkVersion($major:int, $minor:int=-1, $build:int=-1, $internal:int=-1):int 20 | { 21 | var __ver:String = Capabilities.version; 22 | var __split:Array = __ver.split(' '); 23 | var __vList:Array = String(__split[1]).split(','); 24 | //trace('ver:', __ver); 25 | //trace('__vList:', __vList); 26 | if($major > int(__vList[0])) return 1; 27 | else if($major < int(__vList[0])) return -1; 28 | else 29 | { 30 | if($minor>-1) 31 | { 32 | if($minor > int(__vList[1])) return 1; 33 | else if($minor < int(__vList[1])) return -1; 34 | else 35 | { 36 | if($build > -1) 37 | { 38 | if($build > int(__vList[2])) return 1; 39 | else if($build < int(__vList[2])) return -1; 40 | else 41 | { 42 | if($internal > -1) 43 | { 44 | if($internal > int(__vList[3])) return 1; 45 | else if($internal < int(__vList[3])) return -1; 46 | else return 0; 47 | } 48 | return 0; 49 | } 50 | } 51 | return 0; 52 | } 53 | } 54 | return 0; 55 | } 56 | } 57 | } 58 | --------------------------------------------------------------------------------