Showing preview only (544K chars total). Download the full file or copy to clipboard to get everything.
Repository: as3/as3-utils
Branch: master
Commit: 838aad249f53
Files: 569
Total size: 431.8 KB
Directory structure:
gitextract_mxl70_5m/
├── .gitignore
├── Contribution Guidelines.md
├── Libraries to integrate.md
├── NOTES.md
├── README.md
├── TODO.md
├── bin/
│ └── as3-utils.swc
├── build/
│ ├── flexunit/
│ │ └── flexUnitTasks-4.1.0-33.jar
│ └── pmd/
│ ├── LICENSE.txt
│ ├── as3-parser-1.1.jar
│ ├── as3-parser-api-1.1.jar
│ ├── as3-plugin-utils-1.1.jar
│ ├── commons-lang-2.4.jar
│ ├── dom4j-1.6.1.jar
│ ├── flex-pmd-ant-task-1.1.jar
│ ├── flex-pmd-command-line-1.1.jar
│ ├── flex-pmd-command-line-api-1.1.jar
│ ├── flex-pmd-core-1.1.jar
│ ├── flex-pmd-cpd-1.1.jar
│ ├── flex-pmd-cpd-ant-task-1.1.jar
│ ├── flex-pmd-cpd-command-line-1.1.jar
│ ├── flex-pmd-files-1.1.jar
│ ├── flex-pmd-metrics-1.1.jar
│ ├── flex-pmd-metrics-ant-task-1.1.jar
│ ├── flex-pmd-metrics-command-line-1.1.jar
│ ├── flex-pmd-ruleset-1.1.jar
│ ├── flex-pmd-ruleset-api-1.1.jar
│ ├── jsap-2.1.jar
│ ├── plexus-utils-1.0.2.jar
│ └── pmd-4.2.5.jar
├── build.properties
├── build.xml
├── libs/
│ ├── flexunit-4.1.0-33-as3_3.5.0.12683.swc
│ ├── flexunit-cilistener-4.1.0-33-3.5.0.12683.swc
│ ├── flexunit-uilistener-4.1.0-33-3.5.0.12683.swc
│ ├── hamcrest-as3-flex-1.1.3.swc
│ └── mockolate-0.9.3.swc
├── res/
│ └── flex-formatter.properties
├── src/
│ ├── .gitignore
│ ├── deprecated/
│ │ ├── .gitignore
│ │ ├── confine.as
│ │ ├── constrain.as
│ │ ├── getURL.as
│ │ ├── randomBoolean.as
│ │ ├── randomRangeFloat.as
│ │ └── randomRangeInt.as
│ └── utils/
│ ├── align/
│ │ ├── alignCenter.as
│ │ ├── alignLeft.as
│ │ ├── alignRight.as
│ │ ├── alignToRectangleBottom.as
│ │ ├── alignToRectangleCenter.as
│ │ ├── alignToRectangleCenterMiddle.as
│ │ ├── alignToRectangleLeft.as
│ │ ├── alignToRectangleMiddle.as
│ │ ├── alignToRectangleRight.as
│ │ ├── alignToRectangleTop.as
│ │ ├── getPositionToTheRightOf.as
│ │ ├── getPositionUnder.as
│ │ ├── gridAlignSpaceNumber.as
│ │ ├── gridAlignSpaceNumberGap.as
│ │ ├── horizontalAlign.as
│ │ ├── horizontalAlignNoSpace.as
│ │ ├── horizontalAlignSpaceArray.as
│ │ ├── horizontalAlignSpaceNumber.as
│ │ ├── interpolate.as
│ │ ├── interpolateMultiX.as
│ │ ├── interpolateMultiY.as
│ │ ├── interpolateX.as
│ │ ├── interpolateY.as
│ │ ├── verticalAlign.as
│ │ ├── verticalAlignNoSpace.as
│ │ ├── verticalAlignSpaceArray.as
│ │ ├── verticalAlignSpaceNumber.as
│ │ ├── xAlignCenter.as
│ │ ├── xAlignLeft.as
│ │ ├── xAlignRight.as
│ │ ├── yAlignCenter.as
│ │ ├── yAlignLeft.as
│ │ └── yAlignRight.as
│ ├── array/
│ │ ├── addItemsAt.as
│ │ ├── arrayContainsValue.as
│ │ ├── arraysAreEqual.as
│ │ ├── average.as
│ │ ├── contains.as
│ │ ├── containsAll.as
│ │ ├── containsAny.as
│ │ ├── copyArray.as
│ │ ├── createUniqueCopy.as
│ │ ├── equals.as
│ │ ├── getHighestValue.as
│ │ ├── getIndexOfDifference.as
│ │ ├── getItemByKey.as
│ │ ├── getItemByType.as
│ │ ├── getItemsByKey.as
│ │ ├── getItemsByType.as
│ │ ├── getLowestValue.as
│ │ ├── getRandomElement.as
│ │ ├── randomize.as
│ │ ├── removeDuplicates.as
│ │ ├── removeItem.as
│ │ ├── removeItems.as
│ │ ├── removeValueFromArray.as
│ │ ├── retainItems.as
│ │ └── sum.as
│ ├── assert/
│ │ ├── assertArrayContains.as
│ │ ├── assertArrayItemsTypeOf.as
│ │ ├── assertDictionaryKeysTypeOf.as
│ │ ├── assertHasText.as
│ │ ├── assertInstanceOf.as
│ │ ├── assertIsTrue.as
│ │ ├── assertNotNull.as
│ │ └── assertState.as
│ ├── boolean/
│ │ ├── randomBoolean.as
│ │ └── randomChance.as
│ ├── capabilities/
│ │ ├── getPlayerInfo.as
│ │ ├── isAirApplication.as
│ │ ├── isIDE.as
│ │ ├── isMac.as
│ │ ├── isPC.as
│ │ ├── isPlugin.as
│ │ ├── isStandAlone.as
│ │ └── isWeb.as
│ ├── color/
│ │ ├── HSLtoHSV.as
│ │ ├── HSLtoRGB.as
│ │ ├── HSVtoHSL.as
│ │ ├── HSVtoRGB.as
│ │ ├── HueToRGB.as
│ │ ├── RGBToHue.as
│ │ ├── RGBtoHSL.as
│ │ ├── RGBtoHSV.as
│ │ ├── averageBlue.as
│ │ ├── averageColorProperty.as
│ │ ├── averageGreen.as
│ │ ├── averageHue.as
│ │ ├── averageLightness.as
│ │ ├── averageRed.as
│ │ ├── averageSaturation.as
│ │ ├── averageValue.as
│ │ ├── changeContrast.as
│ │ ├── getARGB.as
│ │ ├── getColor.as
│ │ ├── getColorFromDisplayObject.as
│ │ ├── getHexStringFromARGB.as
│ │ ├── getHexStringFromRGB.as
│ │ ├── getRGB.as
│ │ ├── getTransform.as
│ │ ├── interpolateColor.as
│ │ ├── invertColor.as
│ │ ├── randomColor.as
│ │ ├── resetColor.as
│ │ ├── setARGB.as
│ │ ├── setColor.as
│ │ ├── setTransform.as
│ │ ├── toColor.as
│ │ ├── toGrayscale.as
│ │ ├── toHTML.as
│ │ ├── toHexString.as
│ │ └── toRGBComponents.as
│ ├── conversion/
│ │ ├── bitsToBytes.as
│ │ ├── bitsToKilobits.as
│ │ ├── bitsToKilobytes.as
│ │ ├── bytesToBits.as
│ │ ├── bytesToKilobits.as
│ │ ├── bytesToKilobytes.as
│ │ ├── daysToHours.as
│ │ ├── daysToMilliseconds.as
│ │ ├── daysToMinutes.as
│ │ ├── daysToSeconds.as
│ │ ├── degreesToRadians.as
│ │ ├── hoursToDays.as
│ │ ├── hoursToMilliseconds.as
│ │ ├── hoursToMinutes.as
│ │ ├── hoursToSeconds.as
│ │ ├── kilobitsToBits.as
│ │ ├── kilobitsToBytes.as
│ │ ├── kilobitsToKilobytes.as
│ │ ├── kilobytesToBits.as
│ │ ├── kilobytesToBytes.as
│ │ ├── kilobytesToKilobits.as
│ │ ├── millisecondsToDays.as
│ │ ├── millisecondsToHours.as
│ │ ├── millisecondsToMinutes.as
│ │ ├── millisecondsToSeconds.as
│ │ ├── minutesToDays.as
│ │ ├── minutesToHours.as
│ │ ├── minutesToMilliseconds.as
│ │ ├── minutesToSeconds.as
│ │ ├── radiansToDegrees.as
│ │ ├── secondsToDays.as
│ │ ├── secondsToHours.as
│ │ ├── secondsToMilliseconds.as
│ │ └── secondsToMinutes.as
│ ├── cookie/
│ │ ├── getCookie.as
│ │ └── setCookie.as
│ ├── date/
│ │ ├── Calendar.as
│ │ ├── TimeRelationships.as
│ │ ├── Timezone.as
│ │ ├── addWeeks.as
│ │ ├── ceil.as
│ │ ├── clone.as
│ │ ├── compareDates.as
│ │ ├── dayAbbrNames.as
│ │ ├── dayNames.as
│ │ ├── equals.as
│ │ ├── floor.as
│ │ ├── formatDate.as
│ │ ├── formatWeekOf.as
│ │ ├── getAMPM.as
│ │ ├── getCountdownUntil.as
│ │ ├── getDayAbbrName.as
│ │ ├── getDayAsString.as
│ │ ├── getDayName.as
│ │ ├── getDayOfTheYear.as
│ │ ├── getDaysInMonth.as
│ │ ├── getEarliestDate.as
│ │ ├── getFormattedDifferenceFromUTC.as
│ │ ├── getInternetTime.as
│ │ ├── getLastMonday.as
│ │ ├── getLastSunday.as
│ │ ├── getLatestDate.as
│ │ ├── getMeridiem.as
│ │ ├── getMonthAbbrName.as
│ │ ├── getMonthName.as
│ │ ├── getNextDay.as
│ │ ├── getPreviousDay.as
│ │ ├── getShortHour.as
│ │ ├── getShortYear.as
│ │ ├── getStartOfWeek.as
│ │ ├── getTimeBetween.as
│ │ ├── getTimeElapsedString.as
│ │ ├── getTimezone.as
│ │ ├── getUTCDate.as
│ │ ├── getWeekOfTheYear.as
│ │ ├── isDaylightSavings.as
│ │ ├── isInCurrentWeek.as
│ │ ├── isLeapYear.as
│ │ ├── isPast.as
│ │ ├── iso8601ToDate.as
│ │ ├── makeMorning.as
│ │ ├── makeNight.as
│ │ ├── monthAbbrNames.as
│ │ ├── monthNames.as
│ │ ├── parseW3CDTF.as
│ │ ├── timeCode.as
│ │ ├── toW3CDTF.as
│ │ └── toggleAMPM.as
│ ├── dictionary/
│ │ ├── CircularDictionary.as
│ │ ├── getKeys.as
│ │ └── getValues.as
│ ├── display/
│ │ ├── Alignment.as
│ │ ├── IDisplayObject.as
│ │ ├── addChild.as
│ │ ├── applyNaturalScrollRect.as
│ │ ├── bringForward.as
│ │ ├── bringToFront.as
│ │ ├── centerWithin.as
│ │ ├── createBitmap.as
│ │ ├── createThumb.as
│ │ ├── cropBitmapData.as
│ │ ├── duplicateDisplayObject.as
│ │ ├── filterChildrenByProps.as
│ │ ├── findAncestor.as
│ │ ├── findAncestorWithType.as
│ │ ├── fitIntoRect.as
│ │ ├── getChildren.as
│ │ ├── getFullBounds.as
│ │ ├── getParents.as
│ │ ├── isVisible.as
│ │ ├── localToLocal.as
│ │ ├── moveBy.as
│ │ ├── moveTo.as
│ │ ├── originalHeight.as
│ │ ├── originalWidth.as
│ │ ├── relativePos.as
│ │ ├── removeAllChildren.as
│ │ ├── removeAllChildrenByType.as
│ │ ├── removeChild.as
│ │ ├── removeChildAt.as
│ │ ├── scheduleForNextFrame.as
│ │ ├── sendBackward.as
│ │ ├── sendToBack.as
│ │ ├── setProperties.as
│ │ ├── showChildren.as
│ │ ├── stopAllTimelines.as
│ │ ├── sumProps.as
│ │ ├── traceChildren.as
│ │ ├── transformToFitRect.as
│ │ └── wait.as
│ ├── draw/
│ │ ├── createCircleShape.as
│ │ ├── createEllipseShape.as
│ │ ├── createRectangleShape.as
│ │ ├── drawRoundRect.as
│ │ └── drawWedge.as
│ ├── error/
│ │ └── getStackTrace.as
│ ├── frame/
│ │ ├── addFrameScript.as
│ │ ├── getFrameNumberForLabel.as
│ │ └── removeFrameScript.as
│ ├── fullscreen/
│ │ └── toggleFullScreen.as
│ ├── garbageCollection/
│ │ └── gc.as
│ ├── geom/
│ │ ├── Direction.as
│ │ ├── Ellipse.as
│ │ ├── Point3d.as
│ │ ├── Side.as
│ │ ├── angle.as
│ │ ├── cartesianToPolarCoordinates.as
│ │ ├── getRectangleCenter.as
│ │ ├── getRectanglePerimeter.as
│ │ ├── polarToCartesianCoordinates.as
│ │ ├── randomPoint.as
│ │ ├── reverseRectangle.as
│ │ ├── rotatePoint.as
│ │ ├── roundPoint.as
│ │ ├── simplifyAngle.as
│ │ └── trimAngle.as
│ ├── html/
│ │ ├── a.as
│ │ ├── br.as
│ │ ├── entities.as
│ │ ├── img.as
│ │ ├── p.as
│ │ ├── span.as
│ │ └── styledTag.as
│ ├── js/
│ │ └── callJSFunction.as
│ ├── library/
│ │ ├── getBitmapDataFromLibrary.as
│ │ ├── getClassFromLibrary.as
│ │ └── getClipFromLibrary.as
│ ├── load/
│ │ ├── calculateBps.as
│ │ ├── calculateBufferPercent.as
│ │ ├── calculateKBps.as
│ │ ├── calculateMillisecondsUntilBuffered.as
│ │ └── checkDomain.as
│ ├── location/
│ │ ├── getDomain.as
│ │ ├── getLocationName.as
│ │ ├── isDomain.as
│ │ ├── locationNames.as
│ │ ├── openURL.as
│ │ ├── openWindow.as
│ │ └── windowNames.as
│ ├── math/
│ │ ├── Percent.as
│ │ ├── Range.as
│ │ ├── expressAsOdds.as
│ │ └── gcd.as
│ ├── mvc/
│ │ ├── AbstractController.as
│ │ ├── AbstractModel.as
│ │ ├── AbstractView.as
│ │ ├── IController.as
│ │ ├── IModel.as
│ │ └── IView.as
│ ├── number/
│ │ ├── addLeadingZeroes.as
│ │ ├── clamp.as
│ │ ├── createStepsBetween.as
│ │ ├── fastMax2.as
│ │ ├── fastMin2.as
│ │ ├── format.as
│ │ ├── getOrdinalSuffix.as
│ │ ├── getWeightedAverage.as
│ │ ├── hexChars.as
│ │ ├── insertCommas.as
│ │ ├── interpolate.as
│ │ ├── isBetween.as
│ │ ├── isEqual.as
│ │ ├── isEven.as
│ │ ├── isInteger.as
│ │ ├── isNegative.as
│ │ ├── isOdd.as
│ │ ├── isPositive.as
│ │ ├── isPrime.as
│ │ ├── isRoughlyEqual.as
│ │ ├── loopIndex.as
│ │ ├── map.as
│ │ ├── max.as
│ │ ├── min.as
│ │ ├── normalize.as
│ │ ├── pad.as
│ │ ├── randomIntegerWithinRange.as
│ │ ├── randomSign.as
│ │ ├── randomWithinRange.as
│ │ ├── rol.as
│ │ ├── ror.as
│ │ ├── round.as
│ │ ├── roundDecimalToPlace.as
│ │ └── toHex.as
│ ├── object/
│ │ ├── assign.as
│ │ ├── clone.as
│ │ ├── combine.as
│ │ ├── contains.as
│ │ ├── copy.as
│ │ ├── create.as
│ │ ├── createInstance.as
│ │ ├── getKeys.as
│ │ ├── hasAnyProperties.as
│ │ ├── inspect.as
│ │ ├── isEmpty.as
│ │ ├── isNull.as
│ │ ├── isSimple.as
│ │ ├── isUniformPropertyType.as
│ │ ├── merge.as
│ │ ├── numProperties.as
│ │ ├── toArray.as
│ │ └── toString.as
│ ├── range/
│ │ ├── center.as
│ │ ├── isInRange.as
│ │ ├── randomRangeDate.as
│ │ ├── randomRangeSet.as
│ │ └── resolve.as
│ ├── ratio/
│ │ ├── defineRect.as
│ │ ├── heightToWidth.as
│ │ ├── scale.as
│ │ ├── scaleHeight.as
│ │ ├── scaleToFill.as
│ │ ├── scaleToFit.as
│ │ ├── scaleWidth.as
│ │ └── widthToHeight.as
│ ├── string/
│ │ ├── addSlashes.as
│ │ ├── afterFirst.as
│ │ ├── afterLast.as
│ │ ├── arrayList.as
│ │ ├── beforeFirst.as
│ │ ├── beforeLast.as
│ │ ├── beginsWith.as
│ │ ├── between.as
│ │ ├── constants.as
│ │ ├── convertBytesString.as
│ │ ├── detectBr.as
│ │ ├── endsWith.as
│ │ ├── equals.as
│ │ ├── firstToUpper.as
│ │ ├── getLettersFromString.as
│ │ ├── htmlDecode.as
│ │ ├── htmlEncode.as
│ │ ├── ltrim.as
│ │ ├── numberToString.as
│ │ ├── padLeft.as
│ │ ├── padRight.as
│ │ ├── randomCharacters.as
│ │ ├── randomLowercaseCharacters.as
│ │ ├── randomNumberString.as
│ │ ├── randomSequence.as
│ │ ├── randomSpecialCharacters.as
│ │ ├── remove.as
│ │ ├── removeExtraWhitespace.as
│ │ ├── removeSpaces.as
│ │ ├── removeTabs.as
│ │ ├── repeat.as
│ │ ├── replace.as
│ │ ├── reverse.as
│ │ ├── reverseWords.as
│ │ ├── rtrim.as
│ │ ├── sanitizeNull.as
│ │ ├── search.as
│ │ ├── slashUnsafeChars.as
│ │ ├── stringHasValue.as
│ │ ├── stringsAreEqual.as
│ │ ├── stripSlashes.as
│ │ ├── stripTags.as
│ │ ├── toDoubleQuote.as
│ │ ├── toNumeric.as
│ │ ├── toSingleQuote.as
│ │ ├── toTitleCase.as
│ │ ├── trim.as
│ │ ├── trimCamel.as
│ │ ├── truncate.as
│ │ ├── truncate2.as
│ │ ├── wordCount.as
│ │ └── xtrim.as
│ ├── swf/
│ │ └── SWFReader.as
│ ├── textField/
│ │ ├── TextFieldWrapper.as
│ │ ├── clearFields.as
│ │ ├── createField.as
│ │ ├── formatFields.as
│ │ ├── getUsableFonts.as
│ │ ├── hideFields.as
│ │ ├── revealFields.as
│ │ ├── setFormattedText.as
│ │ ├── setStyledText.as
│ │ ├── setTextColor.as
│ │ ├── setTextFont.as
│ │ ├── setTextLeading.as
│ │ ├── setTextLetterSpacing.as
│ │ ├── setTextSpaceWidth.as
│ │ ├── styleFields.as
│ │ ├── truncateMultilineText.as
│ │ └── truncateText.as
│ ├── type/
│ │ ├── PACKAGE_CLASS_SEPARATOR.as
│ │ ├── convertFullyQualifiedName.as
│ │ ├── describeInheritance.as
│ │ ├── describeMethods.as
│ │ ├── describeProperties.as
│ │ ├── describeType.as
│ │ ├── forInstance.as
│ │ ├── forName.as
│ │ ├── getClass.as
│ │ ├── getClassByName.as
│ │ ├── getClassName.as
│ │ ├── getDisplayObjectClass.as
│ │ ├── getFullyQualifiedName.as
│ │ ├── getFullyQualifiedSuperClassname.as
│ │ ├── getName.as
│ │ ├── getNameFromFullyQualifiedName.as
│ │ ├── getPropertyType.as
│ │ ├── getSuperClassName.as
│ │ ├── getType.as
│ │ ├── isInterface.as
│ │ ├── isPassedByValue.as
│ │ ├── isType.as
│ │ ├── newInstance.as
│ │ ├── registerType.as
│ │ ├── strictIs.as
│ │ └── typeCache.as
│ ├── validation/
│ │ ├── US_STATE_ABBREVIATIONS.as
│ │ ├── encodeCreditCardNumber.as
│ │ ├── getCreditCardProvider.as
│ │ ├── isBlank.as
│ │ ├── isCreditCard.as
│ │ ├── isEmail.as
│ │ ├── isNumeric.as
│ │ ├── isPOBox.as
│ │ ├── isURL.as
│ │ ├── isUSAStateAbbreviation.as
│ │ ├── isValidCreditCardNumber.as
│ │ ├── isValidEmailAddress.as
│ │ ├── isValidExpirationDate.as
│ │ └── isValidPhoneNumber.as
│ └── xml/
│ ├── XMLConstants.as
│ ├── getNextSibling.as
│ ├── getPreviousSibling.as
│ ├── getSiblingByIndex.as
│ └── isValidXML.as
└── test/
├── UtilsTestRunner.as
├── UtilsTestSuite.as
└── utils/
├── align/
│ ├── AlignLeftTest.as
│ ├── AlignRightTest.as
│ └── alignCenterTest.as
├── date/
│ ├── GetNextDayTest.as
│ ├── GetPrevDayTest.as
│ ├── GetTimeElapsedStringTest.as
│ └── calendar/
│ └── CalendarTests.as
├── dictionary/
│ └── CircularDictionaryTest.as
├── display/
│ └── FindAncestorTest.as
├── geom/
│ ├── CartesianToPolarCoordinatesTest.as
│ └── PolarToCartesianCoordinatesTest.as
├── number/
│ ├── ClampTest.as
│ └── ToHexTest.as
├── object/
│ ├── CreateInstanceTest.as
│ ├── CreateTest.as
│ ├── MergeTest.as
│ ├── cloneTest.as
│ └── containsTest.as
├── range/
│ └── RandomRangeDateTest.as
├── string/
│ ├── numberToStringTest.as
│ └── stringHasValueTest.as
├── type/
│ ├── IsPassedByValueTest.as
│ └── StrictIsTest.as
├── validation/
│ ├── IsValidEmailAddressTest.as
│ ├── encodeCreditCardNumberTest.as
│ ├── getCreditCardProviderTest.as
│ ├── isBlankTest.as
│ ├── isCreditCardTest.as
│ ├── isEmailTest.as
│ ├── isNumericTest.as
│ ├── isPOBoxTest.as
│ ├── isUSAStateAbbreviationTest.as
│ ├── isUrlTest.as
│ ├── isValidCreditCardNumberTest.as
│ ├── isValidExpirationDateTest.as
│ └── isValidPhoneNumberTest.as
└── xml/
├── GetNextSiblingTest.as
├── GetPreviousSiblingTest.as
├── GetSiblingByIndexTest.as
└── isValidXMLTest.as
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
src/FlexUnitApplication.mxml
src/FlexUnitCompilerApplication.mxml
target
bin/FlexUnitApplication.swf
bin-debug
bin-release
*.iml
.actionScript*
.flex*
.Flex*
.project
.settings/
.DS_Store
launch
org.eclipse.core.resources.prefs
================================================
FILE: Contribution Guidelines.md
================================================
#Contribution Guidelines
As developers, many of us have created our own working set of classes and functions for handling the common programming tasks we come across every day. But why reinvent the wheel? **AS3-Utils** is an attempt to gather together code from all of these disparate libraries into one place in hopes of creating a reusable, well-tested, well-documented, and freely-available unified collection.
If you have code in a personal library / pile of snippets that you'd like to add, please refer to these guidelines.
##What to contribute
###Flash Player Versions
AS3-utils targets Flash Player 10.0+. That said, most of the snippets will work for FP 9. If there is ever a significant need for a FP9 (or 11+) version of the library, we would encourage branching or forking the project to accommodate this.
Please include the minimum Flash Player version in your ASDocs if it requires FP10 or later to compile. (See Documentation below)
Nothing should rely on the Flex framework (or any external libraries).
###Functions vs. Classes
We've been leaning towards a *functions only* approach. This means:
1. You can type `utils.foo.bar` to explore what's available in any IDE.
1. You only have to import the single function you need instead of a class.
1. Fewer dependencies on other pieces of the library. Less reading documents in order to use the functionality you want.
If you have a utility class that you'd like to add to the library, try breaking it into smaller functions before adding it. In other words, don't add `com.you.ArrayUtil`, instead add the functions within as standalone .as files.
As a general guideline, contributors should always favor "snippets" over more complex object-oriented functionality. Basically, you should be able to copy/paste the function into your own class and have it "just work". Anything more complex than that would need to have an argument as to why it belongs in a utils library rather than its own library.
An exception could be made for support classes that are included as internal classes but aren't accessed on their own.
####Constants
Constants that can be used in a general way can be added. If there is a single constant, Pi for example, you can add it as its own standalone .as file.
// PI.as
package utils.number {
public const PI:Number = 3.141;
}
If the constant value is part of an enumeration of values, you may include it in an enumeration class.
// CommonColors.as
package utils.color {
public class CommonColors {
public const RED:uint = 0xFF0000;
public const GREEN:uint = 0x00FF00;
public const BLUE:uint = 0x0000FF;
}
}
###Integrating Libraries
There's a list of libraries to integrate into AS3-utils. If you'd like to pull in the utility functions from them, please do so with respect to the licenses and authors of the original code. Again, this is a snippet library rather than a collection of classes so break down the code into atomic functions with as few dependencies as possible.
###Naming
- Please use self-explanatory names for your functions and avoid using abbreviations. Strive for clarity over brevity. E.g. `truncateMultilineText()`, NOT `truncMLText()`
- Function names should all begin with some kind of _descriptive_ verb. E.g.
- `displayDialog()` NOT `dialog()` or `doDialog()`
- `getName()` or `get name()` NOT `name()`
- Predicate functions, functions that return a boolean must start with `is` (as if answering a question). E.g. `isEmptyString(value:String):Boolean` NOT `empty(value:String):Boolean`
- Parameter names must be descriptive. E.g. `alignLeft(objectsToAlign:Array):void` instead of `alignLeft(a:Array):void`
- Variable names must be descriptive. E.g. `var targetWidth:int = target.width` instead of `var tw:int = target.width`
- Please use US English for all terms. E.g. `getColor()` not `getColour()`
- Remember that in common practice the package name will not be included in people's code. Therefore, to make code more readable, avoid ambiguous names for functions and classes. Rather than relying on the package name to imply what the function does, include include it in the name of the function. E.g.
* `convertHexStringToUint(hexString:String):uint`, NOT `convertToUint(s:String):uint`
* `XMLConstants` or better yet, `XMLNodeType`, NOT `Constants`
* `utils.foo.getFooAsString()`, NOT `utils.foo.toString()`
- When in doubt, use naming conventions from ActionScript and the FlashPlayer API.
###Packages
Here are general guidelines for how to pick a package.
* Check to see what packages already exist before creating a new one. If possible, use one of the existing packages. **Do not** use your own package names (e.g. `com.mimswright`)
* If a utility function operates mainly on a particular class from the Flash Player API, use the same package name as that class. E.g. if your function deals mostly with `Sprites`, use the `utils.display` package.
* If your function is related to a root-level class in the Flash API, such as `Array`, use `utils.array`.
* If you have a significant set of functions that relates to a specific class within a package, you may create a new package just for that class. For example, if you have several functions that all deal with `Point`, could go in `utils.geom.point`.
* If you're Peter Piper, pick a peck of pickled packages.
##Deprecating and Replacing Existing Code
What do you do if you want to contribute a piece of code that is very similar to one that already exists?
* **First, always check for code that could function similarly to your code.**
* If you find similar code to something you want to commit, think carefully.
* If your code and their code do virtually the same thing the same way, suck it up and **keep the existing code**.
* Only edit or replace existing code if there are tests. If there are not tests, write tests against the existing code then replace with your version. Ensure the tests still pass before committing.
* Writing a note explaining why you made the change is encouraged.
* If you find checked-in code that is a duplicate of another piece of code, keep the one that is clearer and more robust and remove the other.
* You may make changes to names of functions if they are unclear or don't meet the naming requirements but in general, try not to change things around based only on your personal style.
##Unit Tests
Needless to say, code should not cause any compile errors or warnings.
New code snippets must be covered by tests. Tests should demonstrate correct usage, with as many unique scenarios as the code is expected to handle. Fringe cases that may throw errors should be demonstrated if possible, e.g. passing `null` to a function that expects a parameter of type `Array`.
Tests should be written using FlexUnit 4.0+.
If you come across code that needs a unit test written for it, you are encouraged to write one. You will earn much karma.
More on FlexUnit and Testing on [Elad Elrom's Blog](http://elromdesign.com/blog/2010/03/10/test-driven-development-tdd-with-flexunit-4-complete-tutorial/).
##Documentation
Please add [ASDoc](http://help.adobe.com/en_US/flex/using/WSd0ded3821e0d52fe1e63e3d11c2f44bb7b-7fe7.html)-style documentation to everything. Your code should have at least these tags in every function or class.
* `@author Your Name`
* `@param paramName Description.` if there are any params
* `@return Type Description.` if not `void`
* `@throws package.ErrorType Description.` if it throws an error
* `@example <listing version="3.0">code</listing>` for example code. (A good habit is write the example first, then the docs, then the tests, then the code.)
* `@playerversion Flash 10.1` If your code will only work on a player later than 9.0
Example code is optional for simple functions but please include a description of what the code is designed to achieve and/or why you might want to use it. Include any licensing that applies to your functions.
Feel free to add docs to other people's code if there are none.
##Merge Strategy
Submitters should follow these steps when contributing code to the project.
__SUBMITTERS:__
1. Create a fork of the project.
1. Make your changes, test, and commit them.
1. When you're ready to integrate the changes into the main branch, create a pull request.
1. Don't merge your own pull request even if you're an admin. Instead, ask for assistance from someone else to review your pull request and merge it into the master.
1. If you're an admin and are anxious with waiting for your pull request to be handled, review and pull someone else's code while you wait.
__ADMINS:__
1. Review the commits by checking them out to a local repository.
1. Ask questions of the submitter or other admins!
1. Write tests & improve docs or request that the submitter do so.
1. Remember to run the test suite before merging code into master.
1. You can reformat the incoming code using the `res/flex-formatter.properties` file. (Optional)
1. Big changes can/should first be merged into a separate integration branch at your discretion.
###Why not merge your own code?
This is a collection made for everyone made up of several people's personal code library. The chances of adding duplicate or idiosyncratic code is very high. Using the pull-request scheme is a great way for us to make sure all the code is being reviewed by *someone* other than the author. The more people who review code the less chance of checking in a duplicate or buggy piece of code.
Furthermore, gitHub is set up to handle a distributed repository workflow very elegantly. If at any point you want to break out and work on your own personal code library, that's easy to do in your own fork.
================================================
FILE: Libraries to integrate.md
================================================
* Sekati - [http://code.google.com/p/sekati/](http://code.google.com/p/sekati/)
* BumpSlide - [http://code.google.com/p/bumpslide/](http://code.google.com/p/bumpslide/)
* as3MathLib - [http://code.google.com/p/as3mathlib/](http://code.google.com/p/as3mathlib/)
* casaLib - [http://casalib.org/about/](http://http://casalib.org/about/)
================================================
FILE: NOTES.md
================================================
# as3-utils
# ISSUES
- parameter names are not descriptive
- variable names are not descriptive
- nomenclature is inconsistent
-- use functional-programming names?
-- use designer friendly names?
-- provide aliases for common functions with multiple common names?
- ASDocs
-- missing tags
-- incorrect descriptions
-- incorrect tags
# Refactoring Guidelines
- predicate methods should be prefixed with is*
# AUDIT
The below is the results of a quick audit of the functions available in as3-utils, and their specific issues.
# ALIGN
alignLeft
alignToRectangleLeft
duplicates
alignRight
alignToRectangleRight
duplicates
align to edges
distribute by edges
grid alignment
hAlign(targets:Array, hSpacing:int = 0, alignment:Alignment = Alignment.LEFT):Array
vAlign(targets:Array, vSpacing:int = 0, alignment:Alignment = Alignment.TOP):Array
gAlign(targets:Array, columns:int, rows:int, hSpacing:int = 0, vSpacing:int = 0, alignment:Alignment = Alignment.TOP_LEFT):Array
gAlign = gridAlign
/**
* Aligns all the target DisplayObjects by their left edge to the left-most target.
*
* Similar to the Flash IDE Alignment panel.
*/
alignLeft(targets:Vector.<DisplayObject>):Vector.<DisplayObject>
/**
* Aligns all the target DisplayObjects by their right edge to the right-most target.
*
* Similar to the Flash IDE Alignment panel.
*/
alignRight(targets:Vector.<DisplayObject>):Vector.<DisplayObject>
/**
* Aligns all the target DisplayObjects by their top edges to the top-most target.
*
* Similar to the Flash IDE Alignment panel.
*/
alignTop(targets:Vector.<DisplayObject>):Vector.<DisplayObject>
/**
* Aligns all the target DisplayObjects by their bottom edges to the bottom-most target.
*
* Similar to the Flash IDE Alignment panel.
*/
alignBottom(targets:Vector.<DisplayObject>):Vector.<DisplayObject>
/**
* Aligns all the target DisplayObjects by their horizontal center edges to the horizontal center of the all the targets.
*
* Similar to the Flash IDE Alignment panel.
*/
alignHorizontalCenter(targets:Vector.<DisplayObject>):Vector.<DisplayObject>
/**
* Aligns all the target DisplayObjects by their vertical center edges to the vertical center of the all the targets.
*
* Similar to the Flash IDE Alignment panel.
*/
alignVerticalCenter(targets:Vector.<DisplayObject>):Vector.<DisplayObject>
alignToLeftEdge(of:DisplayObject, ...targets)
alignLeftEdges(...targets):Array
alignRightEdges(...targets):Array
alignTopEdges(...targets):Array
alignBottomEdges(...targets):Array
alignCenters(...targets):Array
distributeByLeftEdge(...targets):Array
distributeByRightEdge(...targets):Array
distributeByTopEdge(...targets):Array
distributeByBottomEdge(...targets):Array
distributeByHorizontalCenter(...targets):Array
distributeByVerticalCenter(...targets):Array
# ARRAY
utils.array.contains():int
badly named, should be something like numReferencesInArray, arrayRefCount
utils.array.copyArray()
remove, pointless, use array.slice() instead.
utils.array.createUniqueCopy
utils.array.removeDuplicates
duplicates asx.array.unique
utils.array.arraysAreEqual
utils.array.equals
duplicates
utils.array.getHighestValue
utils.array.getLowestValue
use the Array constants, not magic numbers
utils.array.randomize
too much code for what it does
could be faster
utils.array.removeItem
utils.array.removeValueFromArray
duplicates
utils.array.retainItems
duplicates asx.array.union
utils.array.sum
duplicates asx.array.sum
# ASSERT
utils.assert.*
suggestion: use the assertions provided by hamcrest-as3 or flexunit
should throw an AssertionError instead of Error
utils.capabilities.getPlayerInfo
dubious value
# CAPABILITIES
utils.capabilities.isMac
utils.capabilities.isPC
change isMac to be !isPC
DRY
# COLOR
utils.color.randomColor
implementation is whack, why convert to a Number to a String to a Number?
utils.color.toGrayscale
which reference was used for the mix ratios?
# COOKIE
utils.cookie.setCookie
potential global javascript namespace pollution
# DATE
utils.date.toRFC822
missing result examples, and appears to reference the wrong RFC number
utils.date.toW3CDTF
missing result examples
# DISPLAY
utils.display.addTargetToParent
dubious value
uses a switch for two values
uses magic numbers
utils.display.Alignment
values should be same as key
move to utils.align.Alignment
eg BOTTOM_LEFT:String = "BOTTOM_LEFT"
utils.display.sumProps
remove
replace with utils.number.sum, asx.object.pluck
# ERROR
utils.error.getStackTrace
no try-catch required
return new Error().getStackTrace();
dubious value
# EVENT
utils.event.addTargetEventListener
utils.event.removeTargetEventListener
dubious value
# FRAME
utils.frame.addFrameScript
utils.frame.removeFrameScript
needs an appropriate error message
can multiple framescripts exist on a single frame?
# GEOM
utils.geom.Point3D
move static methods to instance method, both deal with Point3D as arguments, and there are already instance methods for add, subtract, offset
# NUMBER
utils.number.clamp
utils.number.confine
utils.number.constrain
utils.range.resolve
duplicates asx.number.bound
replace with clamp
utils.number.insertCommas
there is easier way to do this, using reverse, split and join
utils.number.isBetween
duplicates asx.number.between
# RANGE
utils.range.resolve
duplicates utils.number.clamp etc
# STRING
utils.string.addSlashes
bad name, escapeChars is more accurate
utils.string.slashUnsafeChars
bad name, escapeRegExpChars is more accurate
utils.string.constants
bad name, separate to package level or rename
utils.string.firstToUpper
bad name, rename to capitalize
utils.string.replace
dubious value
utils.string.stripSlashes
bad name, unescapeChars
================================================
FILE: README.md
================================================
# as3-utils
ActionScript 3 Utilities and Object Extensions provided as reusable package-level functions that solve common problems.
# What have you got for me?
HEAPS, too much to list here right now.
Oh ok here's a taste, there are umpteen utils for
- array
- color
- conversions
- date
- event
- garbage collection
- html
- number
- string
- validation
- and [more](http://github.com/as3/as3-utils/tree/master/src/utils/).
# Gimme some utils
Got Git? Lets go!
$ git clone git://github.com/as3/as3-utils.git
$ ant
# Got something to share?
Check out the [contribution guidelines](https://github.com/as3/as3-utils/blob/master/Contribution%20Guidelines.md).
Fork the [as3-utils project](http://github.com/as3/as3-utils) on GitHub, see the [forking guide](http://help.github.com/forking/) and then send a pull request.
# Contributors
- John Lindquist [@johnlindquist](http://twitter.com/johnlindquist)
- Drew Bourne [@drewbourne](http://twitter.com/drewbourne)
- Joel Hooks [@jhooks](http://twitter.com/jhooks)
- Mims H. Wright [@mimshwright](http://twitter.com/mimshwright)
- Ian McLean [@ianmclean](http://twitter.com/ianmclean)
- [You?](https://github.com/as3/as3-utils/blob/master/Contribution%20Guidelines.md)
# Giving credit where credit is due
Many of these utils are copy/pasted from open-source projects from around the web. We will attribute functions to their creators (it's on our list of things to do) and we hope function authors understand that we're not trying to take credit for their work. We don't want credit, we just want a collection of great open-source utils supported by the community.
If you include your own code in the library, please be sure to add a credit for yourself in the comments or use an @author tag in the asDocs.
# License
Since many of the functions in the library are pulled or adapted from other sources, there is no single license that covers everything. However, the intent is for this code to be freely available and editable, a la the MIT license, except where otherwise noted. We've done our best to include appropriate attribution and license where required but if you see something that should not be in here, please let us know and we will remove it.
================================================
FILE: TODO.md
================================================
# TODO
- combine with [asx](http://github.com/drewbourne/asx)
- attribute all functions to proper authors
- check utils for duplicates
- clean package structure
- clean parameter names to be descriptive
- code formatting
- build out tests
- optimize
- documentation
- examples
- replace default FlexPMD ruleset as it is awkward.
================================================
FILE: build/pmd/LICENSE.txt
================================================
Copyright (c) 2009, Adobe Systems, Incorporated
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of the Adobe Systems, Incorporated. nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================
FILE: build.properties
================================================
project.name=as3-utils
build.groupId=as3
build.artifactId=as3-utils
build.version=0.1
build.artifact=${build.artifactId}-${build.version}
test.runner=UtilsTestRunner
test.runner.ext=as
flexunit.version=4.1.0-33
flexsdk.version=3.5.0.12683
flexpmd.version=1.1
================================================
FILE: build.xml
================================================
<?xml version="1.0"?>
<project
name="as3-utils"
basedir="."
default="package">
<!--
as3-utils
usage:
$ ant -v clean package
@author drewbourne
-->
<!-- properties -->
<property environment="env" />
<property file="build.properties" />
<!-- paths: existing -->
<property name="src.loc" location="${basedir}/src" />
<property name="test.loc" location="${basedir}/test" />
<property name="lib.loc" location="${basedir}/libs" />
<property name="build.loc" location="${basedir}/build" />
<property name="build.pmd.loc" location="${build.loc}/pmd" />
<property name="build.flexunit.loc" location="${build.loc}/flexunit" />
<!-- paths: enumerated -->
<property name="dist.loc" location="${basedir}/target" />
<property name="bin.loc" location="${dist.loc}/bin" />
<property name="doc.loc" location="${dist.loc}/doc" />
<property name="report.loc" location="${dist.loc}/report" />
<property name="report.flexunit.loc" location="${report.loc}/flexunit" />
<!-- Flex SDK -->
<property name="FLEX_HOME" location="${env.FLEX_HOME}" />
<!-- task definitions -->
<taskdef resource="flexTasks.tasks"
classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<!-- targets -->
<target
name="clean"
description="Removes generated artifacts and directories">
<delete dir="${dist.loc}" />
</target>
<target
name="initialize"
description="Creates generated directories ">
<mkdir dir="${dist.loc}" />
<mkdir dir="${bin.loc}" />
<mkdir dir="${doc.loc}" />
<mkdir dir="${report.loc}" />
<mkdir dir="${report.flexunit.loc}" />
</target>
<target
name="compile-check-if-required"
description="Checks if a compile is required"
depends="initialize">
<uptodate
property="compile.not-required"
targetfile="${bin.loc}/${build.artifact}.swc">
<srcresources>
<fileset dir="${src.loc}">
<include name="**/*.as" />
<include name="**/*.mxml" />
</fileset>
<fileset dir="${lib.loc}">
<include name="**/*.swc" />
</fileset>
</srcresources>
</uptodate>
</target>
<target
name="compile"
description="Compiles the library"
depends="initialize, compile-check-if-required"
unless="compile.not-required">
<compc output="${bin.loc}/${build.artifact}.swc"
target-player="10.0">
<source-path path-element="${src.loc}" />
<include-sources dir="${src.loc}">
<include name="**/*.as" />
<include name="**/*.mxml" />
</include-sources>
<library-path dir="${lib.loc}" append="true">
<include name="*.swc" />
</library-path>
<compiler.verbose-stacktraces>true</compiler.verbose-stacktraces>
</compc>
</target>
<target name="test"
description="Run the test suite"
depends="initialize">
<taskdef resource="flexUnitTasks.tasks"
classpath="${build.flexunit.loc}/flexUnitTasks-${flexunit.version}.jar" />
<!-- Compile Test -->
<mxmlc
target-player="10.0"
file="${test.loc}/${test.runner}.${test.runner.ext}"
output="${bin.loc}/${test.runner}.swf">
<library-path dir="${bin.loc}" append="true">
<include name="${build.artifact}.swc" />
</library-path>
<library-path dir="${lib.loc}" append="true">
<include name="*.swc" />
</library-path>
<compiler.verbose-stacktraces>true</compiler.verbose-stacktraces>
</mxmlc>
<!-- Execute Tests -->
<flexunit
swf="${bin.loc}/${test.runner}.swf"
toDir="${report.flexunit.loc}"
haltonfailure="false"
verbose="true"
localTrusted="true" />
</target>
<target name="report"
description="Generates test reports from FlexUnit, FlexPMD, FlexCPD, FlexMetrics"
depends="test">
<!-- Generate readable report for FlexUnit -->
<junitreport todir="${report.flexunit.loc}">
<fileset dir="${report.flexunit.loc}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${report.flexunit.loc}/html" />
</junitreport>
<!-- FlexPMD config -->
<path id="flexpmd.base">
<pathelement location="${build.pmd.loc}/as3-parser-${flexpmd.version}.jar" />
<pathelement location="${build.pmd.loc}/as3-parser-api-${flexpmd.version}.jar" />
<pathelement location="${build.pmd.loc}/as3-plugin-utils-${flexpmd.version}.jar" />
<pathelement location="${build.pmd.loc}/flex-pmd-files-${flexpmd.version}.jar" />
<pathelement location="${build.pmd.loc}/pmd-4.2.5.jar" />
</path>
<taskdef name="pmd" classname="com.adobe.ac.pmd.ant.FlexPmdAntTask" classpath="${build.pmd.loc}/flex-pmd-ant-task-${flexpmd.version}.jar">
<classpath>
<path refid="flexpmd.base" />
<pathelement location="${build.pmd.loc}/commons-lang-2.4.jar" />
<pathelement location="${build.pmd.loc}/flex-pmd-core-${flexpmd.version}.jar" />
<pathelement location="${build.pmd.loc}/flex-pmd-ruleset-api-${flexpmd.version}.jar" />
<pathelement location="${build.pmd.loc}/flex-pmd-ruleset-${flexpmd.version}.jar" />
<pathelement location="${build.pmd.loc}/plexus-utils-1.0.2.jar" />
</classpath>
</taskdef>
<taskdef name="cpd" classname="com.adobe.ac.cpd.ant.FlexCpdAntTask" classpath="${build.pmd.loc}/flex-pmd-cpd-ant-task-${flexpmd.version}.jar">
<classpath>
<path refid="flexpmd.base" />
<pathelement location="${build.pmd.loc}/flex-pmd-cpd-${flexpmd.version}.jar" />
</classpath>
</taskdef>
<taskdef name="metrics" classname="com.adobe.ac.pmd.metrics.ant.FlexMetricsAntTask"
classpath="${build.pmd.loc}/flex-pmd-metrics-ant-task-${flexpmd.version}.jar">
<classpath>
<path refid="flexpmd.base" />
<pathelement location="${build.pmd.loc}/commons-lang-2.4.jar" />
<pathelement location="${build.pmd.loc}/dom4j-1.6.1.jar" />
<pathelement location="${build.pmd.loc}/flex-pmd-metrics-${flexpmd.version}.jar" />
<pathelement location="${build.pmd.loc}/flex-pmd-ruleset-api-${flexpmd.version}.jar" />
</classpath>
</taskdef>
<!-- Executions -->
<pmd sourceDirectory="${src.loc}" outputDirectory="${report.loc}" />
<cpd minimumTokenCount="50" outputFile="${report.loc}/cpd.xml">
<fileset dir="${src.loc}">
<include name="**/*.as" />
<include name="**/*.mxml" />
</fileset>
</cpd>
<metrics sourcedirectory="${src.loc}" outputfile="${report.loc}/javancss.xml" />
</target>
<target name="doc"
description="Generate ASDoc for ${ant.project.name}"
depends="initialize">
<!-- Generate asdocs -->
<java jar="${FLEX_HOME}/lib/asdoc.jar" fork="true" failonerror="true">
<arg line="+flexlib '${FLEX_HOME}/frameworks'" />
<arg line="-doc-sources '${src.loc}'" />
<arg line="-source-path+='${src.loc}'" />
<arg line="-output '${doc.loc}'" />
<arg line="-main-title '${project.name} API Documentation'" />
<arg line="-window-title '${project.name} API Documentation'" />
</java>
</target>
<target name="package"
description="Package ${ant.project.name} into a zip"
depends="compile, test, report, doc">
<!-- Create distribution for binaries with docs -->
<zip destfile="${dist.loc}/${build.artifact}.zip">
<zipfileset dir="${bin.loc}">
<include name="${build.artifact}.swc" />
</zipfileset>
<zipfileset dir="${doc.loc}" prefix="doc" />
</zip>
</target>
</project>
================================================
FILE: res/flex-formatter.properties
================================================
#FlexFormatter settings
#Sat Apr 10 22:47:59 EST 2010
ASRearr_UseModifierOrder_Function=true
Actionscript.useBraceStyle=false
ASRearr_ModifierOrder_Property=<Namespace>,override,native,public,private,protected,internal,static,dynamic,final
ASRearr_UseSectionHeadersInMXML=false
ASRearr_ModifierOrder_Class=<Namespace>,override,native,public,private,protected,internal,static,dynamic,final
ASRearr_GroupGettersAndSettersWithStaticProperties=false
ASRearr_ElementSortStaticProperties=true
ASRearr_ElementStaticFunctionVisibilityOrder=public\:true,protected\:true,internal\:true,private\:true,
MXML.attrWrapMode=52
ASRearr_UseElementStaticPropertyVisibilityOrder=true
ASRearr_SortGettersAndSettersWithAssociatedProperties=true
ASRearr_ElementSortImports=true
ASRearr_ElementOrder=Import,Include,Namespace Definition,Default Namespace,Namespace Use,Static Property,Static Function,Static Initializer,Constructor,Property,Function,
Actionscript.spacesAfterComma=1
Actionscript.advancedSpacesAroundEqualsInOptionalParameters=0
ASRearr_ElementFunctionVisibilityOrder=public\:true,protected\:true,internal\:true,private\:true,
MXML.blankLinesAfterSpecificParentTags=0
MXML.onlyFormatASIfCDATABlock=false
Actionscript.advancedWrappingElements=165
Actionscript.spacesBeforeComma=0
Actionscript.advancedSpacesInsideLiteralBraces=1
Actionscript.wrapArrayDeclMode=4
ASRearr_SectionHeaderMap=\#\n\#Sat Apr 10 22\:47\:59 EST 2010\n
ASRearr_RemoveExistingCopyrightHeaders=false
Actionscript.newLineBeforeBindableProperty=true
Flex.useTabs=true
ASRearr_ElementSortMetatags=false
MXML.attrsToKeepOnSameLine=4
MXML.sortAttrMode=0
Actionscript.wrapMethodCallMode=4
Actionscript.spacesBeforeControlOpenParen=1
Actionscript.spacesAfterColons=0
Actionscript.useGlobalCRBeforeBrace=true
Actionscript.blankLinesBeforeFunctions=1
MXML.spacesAroundEquals=0
ASRearr_AddDefaultHeaderForStaticProperties=1
ASRearr_UseModifierOrder_Class=true
Actionscript.breakLinesBeforeComma=false
Actionscript.spacesAroundAssignment=1
ASRearr_ElementSortIncludes=true
MXML.wrapIndentStyle=1001
Actionscript.leaveExtraWhitespaceAroundVarDecls=false
MXML.maxLineLength=200
Actionscript.putEmptyStatementsOnNewLine=true
ActionScript.metatagsOnSameLineAsTargetProperty=Bindable
Actionscript.wrapExpressionMode=4
ASRearr_UseElementStaticFunctionVisibilityOrder=true
Actionscript.spacesAroundColons=0
ASRearr_UseSectionHeaders=false
Actionscript.advancedUseSpacesAroundEqualsInOptionalParameters=true
Actionscript.useAdvancedWrapping=false
Actionscript.putOpenBraceOnNewLine=true
MXML.blankLinesBeforeTags=0
Actionscript.blankLinesBeforeControlStatements=0
ASRearr_RemoveExistingSectionHeaders=false
Actionscript.putWhileOnNewLine=true
Actionscript.advancedCRBeforeBraceSettings=2047
Actionscript.dontIndentPackageItems=false
Actionscript.keepBlankLines=true
MXML.keepBlankLines=true
ASRearr_BlankLinesBeforeElement=
ASRearr_UseMetatagOrder=false
ActionScript.spacesBeforeFormalParameters=0
MXML.attrGroups=name\=properties|sort\=11|includeStates\=true|wrap\=54|attrs\=allowDisjointSelection,allowMultipleSelection,allowThumbOverlap,allowTrackClick,autoLayout,autoRepeat,automationName,cachePolicy,class,clipContent,condenseWhite,conversion,creationIndex,creationPolicy,currentState,data,dataDescriptor,dataProvider,dataTipFormatFunction,dayNames,defaultButton,direction,disabledDays,disabledRanges,displayedMonth,displayedYear,doubleClickEnabled,emphasized,enabled,explicitHeight,explicitMaxHeight,explicitMaxWidth,explicitMinHeight,explicitMinWidth,explicitWidth,firstDayOfWeek,focusEnabled,fontContext,height,horizontalLineScrollSize,horizontalPageScrollSize,horizontalScrollBar,horizontalScrollPolicy,horizontalScrollPosition,htmlText,icon,iconField,id,imeMode,includeInLayout,indeterminate,label,labelField,labelFunction,labelPlacement,labels,layout,lineScrollSize,listData,liveDragging,maxChars,maxHeight,maxScrollPosition,maxWidth,maxYear,maximum,measuredHeight,measuredMinHeight,measuredMinWidth,measuredWidth,menuBarItemRenderer,menuBarItems,menus,minHeight,minScrollPosition,minWidth,minYear,minimum,mode,monthNames,monthSymbol,mouseFocusEnabled,pageScrollSize,pageSize,percentHeight,percentWidth,scaleX,scaleY,scrollPosition,selectable,selectableRange,selected,selectedDate,selectedField,selectedIndex,selectedRanges,showDataTip,showRoot,showToday,sliderDataTipClass,sliderThumbClass,snapInterval,source,states,stepSize,stickyHighlighting,styleName,text,text,thumbCount,tickInterval,tickValues,toggle,toolTip,transitions,truncateToFit,validationSubField,value,value,verticalLineScrollSize,verticalPageScrollSize,verticalScrollBar,verticalScrollPolicy,verticalScrollPosition,width,x,y,yearNavigationEnabled,yearSymbol,|data\=-1|\nname\=xml_namespaces|sort\=11|includeStates\=true|wrap\=54|attrs\=xmlns,xmlns\:.*,|data\=-1|\nname\=events|sort\=11|includeStates\=true|wrap\=54|attrs\=add,added,activate,addedToStage,buttonDown,change,childAdd,childIndexChange,childRemove,clickHandler,clear,click,complete,contextMenu,copy,creationComplete,currentStateChange,currentStateChanging,cut,dataChange,deactivate,doubleClick,dragComplete,dragDrop,dragEnter,dragExit,dragOver,dragStart,effectEnd,effectStart,enterFrame,enterState,exitFrame,exitState,focusIn,focusOut,frameConstructed,hide,httpStatus,init,initialize,invalid,ioError,itemClick,itemRollOut,itemRollOver,keyDown,keyFocusChange,keyUp,menuHide,menuShow,middleClick,middleMouseDown,middleMouseUp,mouseDown,mouseUp,mouseOver,mouseMove,mouseOut,mouseFocusChange,mouseWheel,mouseDownOutside,mouseWheelOutside,move,nativeDragComplete,nativeDragDrop,nativeDragEnter,nativeDragExit,nativeDragOver,nativeDragStart,nativeDragUpdate,open,paste,preinitialize,progress,record,remove,removed,removedFromStage,render,resize,rightClick,rightMouseDown,rightMouseUp,rollOut,rollOver,scroll,securityError,selectAll,show,tabChildrenChange,tabEnabledChange,tabIndexChange,thumbDrag,thumbPress,thumbRelease,toolTipCreate,toolTipEnd,toolTipHide,toolTipShow,toolTipShown,toolTipStart,updateComplete,unload,valid,valueCommit,|data\=-1|\nname\=styles|sort\=11|includeStates\=true|wrap\=54|attrs\=backgroundAlpha,backgroundAttachment,backgroundColor,backgroundDisabledColor,backgroundImage,backgroundSize,backgroundSkin,barColor,barSkin,borderColor,borderSides,borderSkin,borderStyle,borderThickness,bottom,color,cornerRadius,dataTipOffset,dataTipPrecision,dataTipStyleName,disabledColor,disabledIcon,disabledIconColor,disabledSkin,disbledOverlayAlpha,downArrowDisabledSkin,downArrowDownSkin,downArrowOverSkin,downArrowUpSkin,downIcon,downSkin,dropShadowColor,dropShadowEnabled,errorColor,fillAlphas,fillColors,focusAlpha,focusBlendMode,focusRoundedCorners,focusSkin,focusThickness,fontAntiAliasType,fontFamily,fontGridFitType,fontSharpness,fontSize,fontStyle,fontThickness,fontWeight,fontfamily,headerColors,headerStyleName,highlightAlphas,horizontalAlign,horizontalCenter,horizontalGap,horizontalScrollBarStyleName,icon,iconColor,indeterminateMoveInterval,indeterminateSkin,itemDownSkin,itemOverSkin,itemUpSkin,kerning,labelOffset,labelStyleName,labelWidth,leading,left,letterSpacing,maskSkin,menuStyleName,nextMonthDisabledSkin,nextMonthDownSkin,nextMonthOverSkin,nextMonthSkin,nextMonthUpSkin,nextYearDisabledSkin,nextYearDownSkin,nextYearOverSkin,nextYearSkin,nextYearUpSkin,overIcon,overSkin,paddingBottom,paddingLeft,paddingRight,paddingTop,prevMonthDisabledSkin,prevMonthDownSkin,prevMonthOverSkin,prevMonthSkin,prevMonthUpSkin,prevYearDisabledSkin,prevYearDownSkin,prevYearOverSkin,prevYearSkin,prevYearUpSkin,repeatDelay,repeatInterval,right,rollOverColor,rollOverIndicatorSkin,selectedDisabledIcon,selectedDisabledSkin,selectedDownIcon,selectedDownSkin,selectedOverIcon,selectedOverSkin,selectedUpIcon,selectedUpSkin,selectionColor,selectionIndicatorSkin,shadowColor,shadowDirection,shadowDistance,showTrackHighlight,skin,slideDuration,slideEasingFunction,strokeColor,strokeWidth,textAlign,textDecoration,textIndent,textRollOverColor,textSelectedColor,themeColor,thumbDisabledSkin,thumbDownSkin,thumbIcon,thumbOffset,thumbOverSkin,thumbUpSkin,tickColor,tickLength,tickOffset,tickThickness,todayColor,todayIndicatorSkin,todayStyleName,top,tracHighlightSkin,trackColors,trackHeight,trackMargin,trackSkin,upArrowDisabledSkin,upArrowDownSkin,upArrowOverSkin,upArrowUpSkin,upIcon,upSkin,verticalAlign,verticalCenter,verticalGap,verticalScrollBarStyleName,weekDayStyleName,|data\=-1|\nname\=effects|sort\=11|includeStates\=true|wrap\=54|attrs\=addedEffect,completeEffect,creationCompleteEffect,focusInEffect,focusOutEffect,hideEffect,mouseDownEffect,mouseUpEffect,moveEffect,removedEffect,resizeEffect,rollOutEffect,rollOverEffect,showEffect,|data\=-1|\n
ASRearr_UseModifierOrder_Property=true
ASRearr_MoveImportsOutsideClass=true
Actionscript.maxLineLength=200
Actionscript.spacesInsideParens=0
ASRearr_ElementSortProperties=true
Actionscript.advancedSpacesInsideArrayRefBrackets=0
Actionscript.blankLinesToKeep=0
Actionscript.keepElseIfOnSameLine=true
Actionscript.blankLinesBeforeProperties=0
Actionscript.advancedWrappingEnforceMax=false
Actionscript.spacesBeforeColons=0
Actionscript.advancedWrappingPreservePhrases=true
Actionscript.alwaysGenerateIndent=false
ASRearr_UseElementPropertyVisibilityOrder=true
MXML.parentTagsToHaveBlankLinesAddedAfterThem=
Actionscript.spacesAfterLabel=1
ASRearr_AddDefaultHeaderForProperties=1
Actionscript.wrapMethodDeclMode=4
ASRearr_UseCopyrightGeneration=false
Actionscript.useGlobalSpacesAroundColons=true
ASRearr_ModifierOrder_Function=<Namespace>,override,native,public,private,protected,internal,static,dynamic,final
ASRearr_ElementStaticPropertyVisibilityOrder=public\:true,protected\:true,internal\:true,private\:true,
MXML.sortExtraAttrs=false
Actionscript.tabCountForHangingIndent=1
ASRearr_ElementSortFunctions=true
ASRearr_ElementPropertyVisibilityOrder=public\:true,protected\:true,internal\:true,private\:true,
MXML.blankLinesAfterParentTags=0
ASRearr_GroupGettersAndSettersWithProperties=false
Actionscript.wrapEmbeddedXMLMode=2
ASRearr_UseElementOrder=true
Actionscript.doRearrangeWhileFormatting=false
ASRearr_UseGlobalModifierOrder=true
Actionscript.useGlobalSpacesInsideParens=false
ASRearr_MajorSectionHeader=style\=1|width\=60|blankLines\=4|fillChar\=-|text\=|linesBefore\=1|
Actionscript.putCatchOnNewLine=true
ASRearr_CopyrightHeader=style\=1|width\=80|blankLines\=2|fillChar\=-|text\= Copyright 2010\n All rights reserved.|linesBefore\=1|
ASRearr_ElementSortNamespaces=true
Actionscript.putElseOnNewLine=true
MXML.spacesBeforeEmptyTagEnd=0
ASRearr_ElementSortStaticFunctions=true
Actionscript.wrapIndentStyle=1001
ASRearr_MetatagOrder=ArrayElementType,Bindable,DefaultProperty,Deprecated,Effect,Embed,Event,Exclude,ExcludeClass,IconFile,Inspectable,InstanceType,NonCommittingChangeEvent,RemoteClass,Style,SWF,Transient,
Actionscript.braceStyle=5
MXML.alwaysUseMaxLineLength=false
ASRearr_UseElementFunctionVisibilityOrder=true
Actionscript.spacesAroundBinarySymbolicOperator=1
Actionscript.keepSLCommentsOnColumn1=true
Actionscript.newLineBeforeBindableFunction=true
MXML.tagsCanFormat=mx\:List,fx\:List,
MXML.sortAttrData=
ASRearr_MinorSectionHeader=style\=1|width\=40|blankLines\=0|fillChar\=-|text\=|linesBefore\=1|
Actionscript.blankLinesBeforeClasses=1
MXML.tagsToHaveBlankLinesAddedBeforeThem=
MXML.useAttrsToKeepOnSameLine=false
ASRearr_UseImportOrder=true
MXML.blankLinesBetweenSiblingTags=0
Actionscript.collapseSpacesForAdjacentParens=true
Actionscript.advancedSpacesInsideArrayDeclBrackets=1
Actionscript.advancedSpacesInsideParens=0
Actionscript.advancedWrappingGraceColumns=5
MXML.tagsCannotFormat=mx\:String,fx\:String,
MXML.attrsPerLine=1
ASRearr_ImportOrder=adobe,com,flash,mx,
MXML.addNewlineAfterLastAttr=false
MXML.tagsWithASContent=.*\:add,.*\:added,.*\:activate,.*\:addedToStage,.*\:buttonDown,.*\:change,.*\:childAdd,.*\:childIndexChange,.*\:childRemove,.*\:clickHandler,.*\:clear,.*\:click,.*\:complete,.*\:contextMenu,.*\:copy,.*\:creationComplete,.*\:currentStateChange,.*\:currentStateChanging,.*\:cut,.*\:dataChange,.*\:deactivate,.*\:doubleClick,.*\:dragComplete,.*\:dragDrop,.*\:dragEnter,.*\:dragExit,.*\:dragOver,.*\:dragStart,.*\:effectEnd,.*\:effectStart,.*\:enterFrame,.*\:enterState,.*\:exitFrame,.*\:exitState,.*\:focusIn,.*\:focusOut,.*\:frameConstructed,.*\:hide,.*\:httpStatus,.*\:init,.*\:initialize,.*\:invalid,.*\:ioError,.*\:itemClick,.*\:itemRollOut,.*\:itemRollOver,.*\:keyDown,.*\:keyFocusChange,.*\:keyUp,.*\:menuHide,.*\:menuShow,.*\:middleClick,.*\:middleMouseDown,.*\:middleMouseUp,.*\:mouseDown,.*\:mouseUp,.*\:mouseOver,.*\:mouseMove,.*\:mouseOut,.*\:mouseFocusChange,.*\:mouseWheel,.*\:mouseDownOutside,.*\:mouseWheelOutside,.*\:move,.*\:nativeDragComplete,.*\:nativeDragDrop,.*\:nativeDragEnter,.*\:nativeDragExit,.*\:nativeDragOver,.*\:nativeDragStart,.*\:nativeDragUpdate,.*\:open,.*\:paste,.*\:preinitialize,.*\:progress,.*\:record,.*\:remove,.*\:removed,.*\:removedFromStage,.*\:render,.*\:resize,.*\:rightClick,.*\:rightMouseDown,.*\:rightMouseUp,.*\:rollOut,.*\:rollOver,.*\:scroll,.*\:securityError,.*\:selectAll,.*\:show,.*\:tabChildrenChange,.*\:tabEnabledChange,.*\:tabIndexChange,.*\:thumbDrag,.*\:thumbPress,.*\:thumbRelease,.*\:toolTipCreate,.*\:toolTipEnd,.*\:toolTipHide,.*\:toolTipShow,.*\:toolTipShown,.*\:toolTipStart,.*\:updateComplete,.*\:unload,.*\:valid,.*\:valueCommit,.*\:Script,
ActionScript.metatagsOnSameLineAsTargetFunction=Bindable
ASRearr_SortGettersAndSettersWithAssociatedStaticProperties=true
================================================
FILE: src/.gitignore
================================================
FlexUnitApplication.mxml
================================================
FILE: src/deprecated/.gitignore
================================================
================================================
FILE: src/deprecated/confine.as
================================================
package deprecated
{
[Deprecated(replacement="utils.number.clamp")]
/**
* Restricts the <code>value</code> to the <code>min</code> and <code>max</code>
* @param value the number to restrict
* @param min the minimum number for <code>value</code> to be
* @param max the maximum number for <code>value</code> to be
* @return
*/
public function confine(value:Number, min:Number, max:Number):Number {
return value < min ? min : (value > max ? max : value);
}
}
================================================
FILE: src/deprecated/constrain.as
================================================
package deprecated
{
[Deprecated(replacement="utils.number.clamp")]
/**
Determines if value falls within a range; if not it is snapped to the nearest range value.
@param value: Number to determine if it is included in the range.
@param firstValue: First value of the range.
@param secondValue: Second value of the range.
@return Returns either the number as passed, or its value once snapped to nearest range value.
@usageNote The constraint values do not need to be in order.
@example
<code>
trace(NumberUtil.constrain(3, 0, 5)); // Traces 3
trace(NumberUtil.constrain(7, 0, 5)); // Traces 5
</code>
*/
public function constrain(value:Number, firstValue:Number, secondValue:Number):Number
{
return Math.min(Math.max(value, Math.min(firstValue, secondValue)), Math.max(firstValue, secondValue));
}
}
================================================
FILE: src/deprecated/getURL.as
================================================
package deprecated {
import flash.net.URLRequest;
import flash.net.navigateToURL;
[Deprecated(replacement="utils.location.openURL")]
/**
* getURL for ActionScript 3.0. Similar
* to getURL of ActionScript 2.0 in simplicity
* and ease. Errors are suppressed and traced
* to the output window.
*
* @author Trevor McCauley - www.senocular.com
*/ public function getURL(url:String, target:String = null):void {
try {
navigateToURL(new URLRequest(url), target);
}
catch(error:Error) {
trace("[getURL] " + error);
}
}
}
================================================
FILE: src/deprecated/randomBoolean.as
================================================
package deprecated {
[Deprecated(replacement="utils.boolean.randomChance")]
/**
* Returns a Boolean.
* Example code:
* <pre>
* RandomUtils.boolean(); // returns true or false (50% chance of true)
* </pre>
* Another example code:
* <pre>
* RandomUtils.boolean(0.8); // returns true or false (80% chance of true)
* </pre>
* @param chance Chance Number (0-1)
* @return Float Number between min-max exclusive.
* @author Aaron Clinger
* @author Shane McCartney
* @author David Nelson
*/ public function randomBoolean(chance:Number = 0.5):Boolean {
return(Math.random() < chance);
}
}
================================================
FILE: src/deprecated/randomRangeFloat.as
================================================
package deprecated {
[Deprecated(replacement="utils.number.randomWithinRange")]
/**
* Returns a random float number within a given range
*/ public function randomRangeFloat(min:Number, max:Number):Number {
return Math.random() * (max - min) + min;
}
}
================================================
FILE: src/deprecated/randomRangeInt.as
================================================
package deprecated {
[Deprecated(replacement="utils.number.randomIntegerWithinRange")]
/**
* Returns a random int number within a given range
*/ public function randomRangeInt(min:Number, max:Number):Number {
return Math.floor(Math.random() * (max - min + 1) + min);
}
}
================================================
FILE: src/utils/align/alignCenter.as
================================================
package utils.align {
import flash.display.DisplayObject;
/**
* Center align object to target.
*/
public function alignCenter(item:DisplayObject, target:DisplayObject):void {
xAlignCenter(item, target);
yAlignCenter(item, target);
}
}
================================================
FILE: src/utils/align/alignLeft.as
================================================
package utils.align
{
/**
* Aligns all the target DisplayObjects by their left edge to the left-most target.
*
* Similar to the Flash IDE Alignment panel.
*
* Given the following arrangement of targets:
* <code>
* t1
* t2
* t3
* </code>
*
* After calling <code>alignLeft([ t1, t2, t3 ])</code> the arrangment will be:
* <code>
* t1
* t2
* t3
* </code>
*
* @param targets Array of DisplayObject (or Object with an <code>x</code> property like <code>Point</code>).
* @return targets Array.
*
* @example
* <listing version="3.0">
* var t1:Sprite = new Sprite();
* t1.x = 5;
*
* var t2:Sprite = new Sprite();
* t2.x = 30;
*
* var t3:Sprite = new Sprite();
* t3.x = 15;
*
* var targets:Array = [t1, t2, t3];
* alignLeft(targets);
*
* trace(t1.x, t2.x t3.x);
* // 5 5 5
* </listing>
*
* @author drewbourne
*/
public function alignLeft(targets:Array):Array
{
var minX:Number = Number.MAX_VALUE;
var targetX:Number;
var target:Object;
for each (target in targets)
{
targetX = target.x;
if (targetX < minX)
minX = targetX;
}
for each (target in targets)
{
target.x = minX;
}
return targets;
}
}
================================================
FILE: src/utils/align/alignRight.as
================================================
package utils.align
{
/**
* Aligns all the target DisplayObjects by their left edge to the left-most target.
*
* Similar to the Flash IDE Alignment panel.
*
* Given the following arrangement of targets:
* <code>
* t1
* t2
* t3
* </code>
*
* After calling <code>alignRight([ t1, t2, t3 ])</code> the arrangment will be:
* <code>
* t1
* t2
* t3
* </code>
*
* @param targets Array of DisplayObject
* or Object with an <code>x</code> property like <code>Point</code>
* or Object with an <code>x</code> and <code>width</code> properties like <code>Rectangle</code>.
*
* @return targets Array.
*
* @example
* <listing version="3.0">
*
* </listing>
*
* @author drewbourne
*/
public function alignRight(targets:Array):Array
{
var maxX:Number = Number.MIN_VALUE;
var targetW:Number;
var targetX:Number;
var target:Object;
for each (target in targets)
{
targetW = "width" in target ? target["width"] : 0;
targetX = target.x + targetW;
if (targetX > maxX)
maxX = targetX;
}
for each (target in targets)
{
targetW = "width" in target ? target["width"] : 0;
target.x = maxX - targetW;
}
return targets;
}
}
================================================
FILE: src/utils/align/alignToRectangleBottom.as
================================================
package utils.align
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
Aligns a DisplayObject to the bottom of the bounding Rectangle.
@param displayObject The DisplayObject to align.
@param bounds The area in which to align the DisplayObject.
@param snapToPixel Force the position to whole pixels <code>true</code>, or to let the DisplayObject be positioned on sub-pixels <code>false</code>.
@param outside Align the DisplayObject to the outside of the bounds <code>true</code>, or the inside <code>false</code>.
*/
public function alignToRectangleBottom(displayObject:DisplayObject, bounds:Rectangle, snapToPixel:Boolean = true, outside:Boolean = false):void
{
var y:Number = outside ? bounds.bottom : bounds.bottom - displayObject.height;
displayObject.y = snapToPixel ? Math.round(y) : y;
}
}
================================================
FILE: src/utils/align/alignToRectangleCenter.as
================================================
package utils.align
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
Aligns a DisplayObject to the horizontal center of the bounding Rectangle.
@param displayObject: The DisplayObject to align.
@param bounds: The area in which to align the DisplayObject.
@param snapToPixel: Force the position to whole pixels <code>true</code>, or to let the DisplayObject be positioned on sub-pixels <code>false</code>.
*/
public function alignToRectangleCenter(displayObject:DisplayObject, bounds:Rectangle, snapToPixel:Boolean = true):void
{
var centerX:Number = bounds.width * 0.5 - displayObject.width * 0.5 + bounds.x;
displayObject.x = snapToPixel ? Math.round(centerX) : centerX;
}
}
================================================
FILE: src/utils/align/alignToRectangleCenterMiddle.as
================================================
package utils.align
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
Aligns a DisplayObject to the horizontal center and vertical middle of the bounding Rectangle.
@param displayObject: The DisplayObject to align.
@param bounds: The area in which to align the DisplayObject.
@param snapToPixel: Force the position to whole pixels <code>true</code>, or to let the DisplayObject be positioned on sub-pixels <code>false</code>.
*/
public function alignToRectangleCenterMiddle(displayObject:DisplayObject, bounds:Rectangle, snapToPixel:Boolean = true):void
{
alignToRectangleCenter(displayObject, bounds, snapToPixel);
alignToRectangleMiddle(displayObject, bounds, snapToPixel);
}
}
================================================
FILE: src/utils/align/alignToRectangleLeft.as
================================================
package utils.align
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
Aligns a DisplayObject to the left side of the bounding Rectangle.
@param displayObject: The DisplayObject to align.
@param bounds: The area in which to align the DisplayObject.
@param snapToPixel: Force the position to whole pixels <code>true</code>, or to let the DisplayObject be positioned on sub-pixels <code>false</code>.
@param outside: Align the DisplayObject to the outside of the bounds <code>true</code>, or the inside <code>false</code>.
*/
public function alignToRectangleLeft(displayObject:DisplayObject, bounds:Rectangle, snapToPixel:Boolean = true, outside:Boolean = false):void
{
var x:Number = outside ? bounds.left - displayObject.width : bounds.left;
displayObject.x = snapToPixel ? Math.round(x) : x;
}
}
================================================
FILE: src/utils/align/alignToRectangleMiddle.as
================================================
package utils.align
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
Aligns a DisplayObject to the vertical middle of the bounding Rectangle.
@param displayObject: The DisplayObject to align.
@param bounds: The area in which to align the DisplayObject.
@param snapToPixel: Force the position to whole pixels <code>true</code>, or to let the DisplayObject be positioned on sub-pixels <code>false</code>.
*/
public function alignToRectangleMiddle(displayObject:DisplayObject, bounds:Rectangle, snapToPixel:Boolean = true):void
{
var centerY:Number = bounds.height * 0.5 - displayObject.height * 0.5 + bounds.y;
displayObject.y = snapToPixel ? Math.round(centerY) : centerY;
}
}
================================================
FILE: src/utils/align/alignToRectangleRight.as
================================================
package utils.align
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
Aligns a DisplayObject to the right side of the bounding Rectangle.
@param displayObject: The DisplayObject to align.
@param bounds: The area in which to align the DisplayObject.
@param snapToPixel: Force the position to whole pixels <code>true</code>, or to let the DisplayObject be positioned on sub-pixels <code>false</code>.
@param outside: Align the DisplayObject to the outside of the bounds <code>true</code>, or the inside <code>false</code>.
*/
public function alignToRectangleRight(displayObject:DisplayObject, bounds:Rectangle, snapToPixel:Boolean = true, outside:Boolean = false):void
{
var x:Number = outside ? bounds.right : bounds.right - displayObject.width;
displayObject.x = snapToPixel ? Math.round(x) : x;
}
}
================================================
FILE: src/utils/align/alignToRectangleTop.as
================================================
package utils.align
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
Aligns a DisplayObject to the top of the bounding Rectangle.
@param displayObject: The DisplayObject to align.
@param bounds: The area in which to align the DisplayObject.
@param snapToPixel: Force the position to whole pixels <code>true</code>, or to let the DisplayObject be positioned on sub-pixels <code>false</code>.
@param outside: Align the DisplayObject to the outside of the bounds <code>true</code>, or the inside <code>false</code>.
*/
public function alignToRectangleTop(displayObject:DisplayObject, bounds:Rectangle, snapToPixel:Boolean = true, outside:Boolean = false):void
{
var y:Number = outside ? bounds.top - displayObject.height : bounds.top;
displayObject.y = snapToPixel ? Math.round(y) : y;
}
}
================================================
FILE: src/utils/align/getPositionToTheRightOf.as
================================================
package utils.align
{
import flash.display.DisplayObject;
import utils.ratio.widthToHeight;
/**
* Gets the position to the right of an object based on its width and x position
* with an optional gap.
*
* This is useful when you need to cause object B to appear 20px to the right of object A.
*
* B.x = getPositionToTheRightOf(A, 20);
*
* @param displayObject An object to get the position under.
* @param gap An optional amount to space out the position under.
*/
public function getPositionToTheRightOf(displayObject:DisplayObject, gap:int = 0):int {
return displayObject.x + displayObject.width + gap;
}
}
================================================
FILE: src/utils/align/getPositionUnder.as
================================================
package utils.align {
import flash.display.DisplayObject;
/**
* Gets the position under an object based on its height and y position with an optional gap.
*
* This is useful when you need to cause object B to appear 20px below object A.
*
* B.y = getPositionUnder(A, 20);
*
* @param displayObject An object to get the position under.
* @param gap An optional amount to space out the position under.
*/
public function getPositionUnder(displayObject:DisplayObject, gap:int = 0):int {
return displayObject.y + displayObject.height + gap;
}
}
================================================
FILE: src/utils/align/gridAlignSpaceNumber.as
================================================
package utils.align
{
/**
* Aligns the items in the array in a grid based on the number of rows and columns.
* Uses the same spacing for all.
*
* @example <listing version="3.0">Alignment.hAlignSpaceNum( [ clip0, clip1, clip2], 10 );</listing>
*
* @param items An array of items
* @param rows The number of rows
* @param cols The number of columns
* @param spacing The spacing between items in pixels
*/
public function gridAlignSpaceNumber(items:Array, rows:Number, cols:Number, spacing:Number = 0):void
{
var col:Number = 0;
var row:Number = 1;
var yPos:Number = 0;
var xPos:Number = 0;
var maxHeightCurrentRow:Number = 0;
var maxHeightPreviousRow:Number = 0;
var n:int = items.length;
for (var i:Number = 0; i < n; i++)
{
if (row <= rows)
{
items[i].x = xPos;
if (col == (cols - 1))
{
xPos = 0;
row++;
}
else
{
xPos += items[(i)].width + spacing;
}
if (col == cols)
{
col = 0;
/*
* Get the max item height from previous row
*/
maxHeightPreviousRow = maxHeightCurrentRow;
maxHeightCurrentRow = items[(i)].height;
yPos += maxHeightPreviousRow + spacing;
}
else
{
/*
* Calculate the max item height from previous row
*/
maxHeightCurrentRow = Math.max(maxHeightCurrentRow, items[(i)].height);
}
items[i].y = yPos;
col++;
}
else
{
break;
}
}
}
}
================================================
FILE: src/utils/align/gridAlignSpaceNumberGap.as
================================================
package utils.align
{
/**
* Aligns the items in the array in a grid based on the number of rows and columns.
* Uses the same spacing for all
*
* @example <listing version="3.0">Alignment.hAlignSpaceNum( [ clip0, clip1, clip2], 10 );</listing>
*
* @param items An array of items
* @param rows The number of rows
* @param cols The number of columns
* @param hGap The column width
* @param vGap The row height
* @param spacing The spacing between items in pixels
*/
public function gridAlignSpaceNumberGap(items:Array, rows:Number, cols:Number, hGap:Number, vGap:Number, spacing:Number = 0):void
{
var col:Number = 0;
var row:Number = 1;
var yPos:Number = 0;
var xPos:Number = 0;
var n:int = items.length;
for (var i:Number = 0; i < n; i++)
{
if (row <= rows)
{
items[i].x = xPos;
if (col == (cols - 1))
{
xPos = 0;
row++;
}
else
{
xPos += hGap + spacing;
}
if (col == cols)
{
col = 0;
yPos += vGap + spacing;
}
items[i].y = yPos;
col++;
}
else
break;
}
}
}
================================================
FILE: src/utils/align/horizontalAlign.as
================================================
package utils.align {
/**
* Convenient horizontal align method with optional alignment argument
* @example <listing version="3.0">Alignment.hAlign( [ clip0, clip1, clip2], 10 );</listing>
* @param items An array of items
* @param args spacing The spacing between items in pixels as either a number or array or blank
*/
public function horizontalAlign(items:Array, ... args):void {
if(args.length > 0) {
if(args[0] is Array)
horizontalAlignSpaceArray(items, args[0]);
if(args[0] is Number)
horizontalAlignSpaceNumber(items, args[0]);
}
else
horizontalAlignNoSpace(items);
}
}
================================================
FILE: src/utils/align/horizontalAlignNoSpace.as
================================================
package utils.align
{
/**
* Aligns each item horizontally to the one above it.
* Uses no spacing.
*
* @example <listing version="3.0">Alignment.hAlignNoSpace( [ clip0, clip1, clip2] );</listing>
*
* @param items An array of items
*/
public function horizontalAlignNoSpace(items:Array):void
{
var n:int = items.length;
for (var i:int = 1; i < n; i++)
{
items[i].x = items[(i - 1)].y + items[(i - 1)].width;
}
}
}
================================================
FILE: src/utils/align/horizontalAlignSpaceArray.as
================================================
package utils.align {
/**
* Aligns each item in the array to the one preceding it.
* Uses the correlating position in the spacing arr for the spacing.
* @example <listing version="3.0">Alignment.hAlignSpaceArr( [ clip0, clip1, clip2], [ 0, 5, 30 ] );</listing>
* @param items An array of items
* @param spacing The array for spacing between items in pixels
*/
public function horizontalAlignSpaceArray(items:Array, spacing:Array):void {
var n:int = items.length;
for(var i:int = 1; i < n; i++) {
items[i].x = items[(i - 1)].x + items[(i - 1)].width + spacing[i];
}
}
}
================================================
FILE: src/utils/align/horizontalAlignSpaceNumber.as
================================================
package utils.align
{
/**
* Aligns the items in the array horizontally to each the one preceding it in the array.
* Uses the same spacing for all.
*
* @example <listing version="3.0">Alignment.hAlignSpaceNum( [ clip0, clip1, clip2], 10 );</listing>
*
* @param items An array of items
* @param spacing The spacing between items in pixels
*/
public function horizontalAlignSpaceNumber(items:Array, spacing:Number):void
{
var n:int = items.length;
for (var i:int = 1; i < n; i++)
{
items[i].x = items[(i - 1)].x + items[(i - 1)].width + spacing;
}
}
}
================================================
FILE: src/utils/align/interpolate.as
================================================
package utils.align
{
import flash.display.DisplayObject;
/**
* interpolate the DisplayObject at weight t == (0 <= t <= 1). a position 1 would position the object to the
* right-most bounds, and tx=0 would position to the left
*
* @param object DisplayObject to position
* @param tx weight of horizontal position from 0 to 1
* @param ty weight of verticle position from 0 to 1
* @param width width of horizontal constraint
* @param height height of the verticle constraint
* @offsetX the left offset of the horizontal constraint (default = 0)
* @offsetY the topmost offset of verticle constraint (default = 0)
*/
public function interpolate(object:DisplayObject, tx:Number, ty:Number, width:Number, height:Number, offsetX:int = 0, offsetY:int = 0):void
{
object.x = (width * tx) + offsetX - (tx * object.width);
object.y = (height * ty) + offsetY - (ty * object.height);
}
}
================================================
FILE: src/utils/align/interpolateMultiX.as
================================================
package utils.align
{
/**
* interpolate multiple DisplayObjects at multiple weights at t == (0 less or equal t less or equal 1). at tx=1, the position of the object would be aligned to the right-most bounds, and tx=0 would position to the left
*
* @param DisplayObject DisplayObject to position
* @param positionArray weight array of horizontal position from 0 to 1
* @param width width of horizontal constraint
* @offsetX the left offset of the horizontal constraint (default = 0)
*/
public function interpolateMultiX(objectArray:Array, positionArray:Array, width:Number, offsetX:int = 0):void
{
var j:int = objectArray.length;
for (var i:int = 0; i < j; i++)
{
interpolateX(objectArray[i], positionArray[i], width, offsetX);
}
}
}
================================================
FILE: src/utils/align/interpolateMultiY.as
================================================
package utils.align
{
/**
* interpolate multiple DisplayObjects at multiple weights at t == (0 less or equal t less or equal 1). at tx=1, the position of the object would be aligned to the right-most bounds, and ty=0 would position to the left
*
* @param DisplayObject DisplayObject to position
* @param positionArray weight array of vertical position from 0 to 1
* @param height width of horizontal constraint
* @param offsetY the left offset of the horizontal constraint (default = 0)
*/
public function interpolateMultiY(objectArray:Array, positionArray:Array, height:Number, offsetY:int = 0):void
{
var j:int = objectArray.length;
for (var i:int = 0; i < j; i++)
{
interpolateX(objectArray[i], positionArray[i], height, offsetY);
}
}
}
================================================
FILE: src/utils/align/interpolateX.as
================================================
package utils.align
{
import flash.display.DisplayObject;
/**
* interpolate the DisplayObject at weight t to the rectangle, ie, a weight of 1 would position the object to the right-most bounds
*
* @param DisplayObject DisplayObject to position
* @param tx
* @param width width of horizontal constraint
* @param offsetX the left offset of the horizontal constraint (default = 0)
*/
public function interpolateX(object:DisplayObject, tx:Number, width:Number, offsetX:int = 0):void
{
object.x = (width * tx) + offsetX - (tx * object.width);
}
}
================================================
FILE: src/utils/align/interpolateY.as
================================================
package utils.align
{
import flash.display.DisplayObject;
/**
* interpolate the DisplayObject at weight t == (0 less or equal t less or equal 1). a position 1 would position the object to the right-most bounds, and tx=0 would position to the left
*
* @param DisplayObject DisplayObject to position
* @param ty weight of verticle position from 0 to 1
* @param height height of the verticle constraint
* @offsetY the left offset of the horizontal constraint (default = 0)
*/
public function interpolateY(object:DisplayObject, ty:Number, height:Number, offsetY:int = 0):void
{
object.y = (height * ty) + offsetY - (ty * object.height);
}
}
================================================
FILE: src/utils/align/verticalAlign.as
================================================
package utils.align {
/**
* Convenient vertical align method with optional alignment argument
* @example <listing version="3.0">Alignment.vAlign( [ clip0, clip1, clip2], 10 );</listing>
* @param items An array of items
* @param spacingValues spacing The spacing between items in pixels as either a number or array or blank
*/
public function verticalAlign(items:Array, ... spacingValues):void {
if(spacingValues.length > 0) {
if(spacingValues[0] is Array)
verticalAlignSpaceArray(items, spacingValues[0]);
if(spacingValues[0] is Number)
verticalAlignSpaceNumber(items, spacingValues[0]);
}
else
verticalAlignNoSpace(items);
}
}
================================================
FILE: src/utils/align/verticalAlignNoSpace.as
================================================
package utils.align
{
/**
* Aligns each item vertically to the one above it.
* Uses no spacing.
*
* @example <listing version="3.0">Alignment.valignNoSpace( [ clip0, clip1, clip2] );</listing>
*
* @param items An array of items
*/
public function verticalAlignNoSpace(items:Array):void
{
var n:int = items.length;
for (var i:int = 1; i < n; i++)
{
items[i].y = int(items[(i - 1)].y + items[(i - 1)].height);
}
}
}
================================================
FILE: src/utils/align/verticalAlignSpaceArray.as
================================================
package utils.align {
/**
* Aligns each item in the array to the one preceding it.
* Uses the correlating position in the spacing arr for the spacing.
* @example <listing version="3.0">Alignment.valignSpaceArr( [ clip0, clip1, clip2], [ 0, 5, 30 ] );</listing>
* @param items An array of items
* @param spacing The array for spacing between items in pixels
*/
public function verticalAlignSpaceArray(items:Array, spacing:Array):void {
var n:int = items.length;
for(var i:int = 1; i < n; i++) {
items[i].y = int(items[(i - 1)].y + items[(i - 1)].height + spacing[i]);
}
}
}
================================================
FILE: src/utils/align/verticalAlignSpaceNumber.as
================================================
package utils.align
{
import flash.text.TextField;
/**
* Aligns the items in the array vertically to each the one preceding it in the array.
* Uses the same spacing for all.
*
* @example <listing version="3.0">Alignment.valignSpaceNum( [ clip0, clip1, clip2], 10 );</listing>
*
* @param items An array of items
* @param spacing The spacing between items in pixels
*/
public function verticalAlignSpaceNumber(items:Array, spacing:Number):void
{
var n:int = items.length;
for (var i:int = 1; i < n; i++)
{
if (items[i - 1] is TextField)
{
items[i].y = int(items[(i - 1)].y + items[(i - 1)].textHeight + spacing);
}
else
{
items[i].y = int(items[(i - 1)].y + items[(i - 1)].height + spacing);
}
}
}
}
================================================
FILE: src/utils/align/xAlignCenter.as
================================================
package utils.align
{
import flash.display.DisplayObject;
import flash.geom.Point;
import flash.geom.Rectangle;
/**
* Horizontal center align object to target.
* Alignment algorithm taken from:
* http://chargedweb.com/labs/2010/07/27/alignutil_align_objects_easily/
* Copyright 2010 Julius Loa | jloa@chargedweb.com
* license: MIT {http://www.opensource.org/licenses/mit-license.php}
*
* This algorith takes the objects rotation and scale into account.
*/
public function xAlignCenter(item:DisplayObject, target:DisplayObject):void
{
//item.x = int(target.width / 2 - item.width / 2);
var b:Rectangle = item.transform.pixelBounds;
var bp:Point = target.globalToLocal(new Point(b.x, b.y));
b.x = bp.x; b.y = bp.y;
item.x = int((target.width - b.width)/2 + item.x - b.x);
}
}
================================================
FILE: src/utils/align/xAlignLeft.as
================================================
package utils.align
{
import flash.display.DisplayObject;
/**
* Horizontal left align object to target.
*/
public function xAlignLeft(item:DisplayObject, target:DisplayObject):void
{
item.x = int(target.x);
}
}
================================================
FILE: src/utils/align/xAlignRight.as
================================================
package utils.align
{
import flash.display.DisplayObject;
/**
* Horizontal right align object to target.
*/
public function xAlignRight(item:DisplayObject, target:DisplayObject):void
{
item.x = int(target.width - item.width);
}
}
================================================
FILE: src/utils/align/yAlignCenter.as
================================================
package utils.align
{
import flash.display.DisplayObject;
import flash.geom.Point;
import flash.geom.Rectangle;
/**
* Vertical center align object to target.
*
* Alignment algorithm taken from:
* http://chargedweb.com/labs/2010/07/27/alignutil_align_objects_easily/
* Copyright 2010 Julius Loa | jloa@chargedweb.com
* license: MIT {http://www.opensource.org/licenses/mit-license.php}
*
* This algorith takes the objects rotation and scale into account.
*/
public function yAlignCenter(item:DisplayObject, target:DisplayObject):void
{
var b:Rectangle = item.transform.pixelBounds;
var bp:Point = target.globalToLocal(new Point(b.x, b.y));
b.x = bp.x; b.y = bp.y;
item.y = int((target.height - b.height)/2 + item.y - b.y);
}
}
================================================
FILE: src/utils/align/yAlignLeft.as
================================================
package utils.align
{
import flash.display.DisplayObject;
/**
* Vertical left align object to target.
*/
public function yAlignLeft(item:DisplayObject, target:DisplayObject):void
{
item.y = int(target.y);
}
}
================================================
FILE: src/utils/align/yAlignRight.as
================================================
package utils.align
{
import flash.display.DisplayObject;
/**
* Vertical right align object to target.
*/
public function yAlignRight(item:DisplayObject, target:DisplayObject):void
{
item.y = int(target.height - item.height);
}
}
================================================
FILE: src/utils/array/addItemsAt.as
================================================
package utils.array
{
/**
Modifies original Array by adding all the elements from another Array at a specified position.
@param tarArray: Array to add elements to.
@param items: Array of elements to add.
@param index: Position where the elements should be added.
@return Returns <code>true</code> if the Array was changed as a result of the call; otherwise <code>false</code>.
@example
<listing version="3.0">
var alphabet:Array = new Array("a", "d", "e");
var parts:Array = new Array("b", "c");
ArrayUtil.addItemsAt(alphabet, parts, 1);
trace(alphabet);
</listing>
*/
public function addItemsAt(tarArray:Array, items:Array, index:int = 0x7FFFFFFF):Boolean
{
if (items.length == 0)
return false;
var args:Array = items.concat();
args.splice(0, 0, index, 0);
tarArray.splice.apply(null, args);
return true;
}
}
================================================
FILE: src/utils/array/arrayContainsValue.as
================================================
package utils.array
{
/**
* Determines whether the specified array contains the specified value.
*
* @param arr The array that will be checked for the specified value.
*
* @param value The object which will be searched for within the array
*
* @return True if the array contains the value, False if it does not.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*/
public function arrayContainsValue(arr:Array, value:Object):Boolean
{
return (arr.indexOf(value) != -1);
}
}
================================================
FILE: src/utils/array/arraysAreEqual.as
================================================
package utils.array {
/**
* Compares two arrays and returns a boolean indicating whether the arrays
* contain the same values at the same indexes.
*
* @param arr1 The first array that will be compared to the second.
*
* @param arr2 The second array that will be compared to the first.
*
* @return True if the arrays contains the same values at the same indexes.
False if they do not.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*/
public function arraysAreEqual(arr1:Array, arr2:Array):Boolean {
if(arr1.length != arr2.length) {
return false;
}
var len:Number = arr1.length;
for(var i:Number = 0; i < len; i++) {
if(arr1[i] != arr2[i]) {
return false;
}
}
return true;
}
}
================================================
FILE: src/utils/array/average.as
================================================
package utils.array
{
/**
Averages the values in <code>inArray</code>.
@param inArray: Array composed only of numbers.
@return The average of all numbers in the <code>inArray</code>.
@example
<listing version="3.0">
var numberArray:Array = new Array(2, 3, 8, 3);
trace("Average is: " + ArrayUtil.average(numberArray));
</listing>
*/
public function average(inArray:Array):Number
{
if (inArray.length == 0)
return 0;
return sum(inArray) / inArray.length;
}
}
================================================
FILE: src/utils/array/contains.as
================================================
package utils.array
{
/**
Finds out how many instances of <code>item</code> Array contains.
@param inArray: Array to search for <code>item</code> in.
@param item: Object to find.
@return The amount of <code>item</code>'s found; if none were found returns <code>0</code>.
@example
<code>
var numberArray:Array = new Array(1, 2, 3, 7, 7, 7, 4, 5);
trace("numberArray contains " + ArrayUtil.contains(numberArray, 7) + " 7's.");
</code>
*/
public function contains(inArray:Array, item:*):uint
{
var i:int = inArray.indexOf(item, 0);
var t:uint = 0;
while (i != -1)
{
i = inArray.indexOf(item, i + 1);
t++;
}
return t;
}
}
================================================
FILE: src/utils/array/containsAll.as
================================================
package utils.array
{
/**
Determines if Array contains all items.
@param inArray: Array to search for <code>items</code> in.
@param items: Array of elements to search for.
@return Returns <code>true</code> if <code>inArray</code> contains all elements of <code>items</code>; otherwise <code>false</code>.
@example
<code>
var numberArray:Array = new Array(1, 2, 3, 4, 5);
trace(ArrayUtil.containsAll(numberArray, new Array(1, 3, 5)));
</code>
*/
public function containsAll(inArray:Array, items:Array):Boolean
{
var l:uint = items.length;
while (l--)
if (inArray.indexOf(items[l]) == -1)
return false;
return true;
}
}
================================================
FILE: src/utils/array/containsAny.as
================================================
package utils.array
{
/**
Determines if Array <code>inArray</code> contains any element of Array <code>items</code>.
@param inArray: Array to search for <code>items</code> in.
@param items: Array of elements to search for.
@return Returns <code>true</code> if <code>inArray</code> contains any element of <code>items</code>; otherwise <code>false</code>.
@example
<code>
var numberArray:Array = new Array(1, 2, 3, 4, 5);
trace(ArrayUtil.containsAny(numberArray, new Array(9, 3, 6)));
</code>
*/
public function containsAny(inArray:Array, items:Array):Boolean
{
var l:uint = items.length;
while (l--)
if (inArray.indexOf(items[l]) > -1)
return true;
return false;
}
}
================================================
FILE: src/utils/array/copyArray.as
================================================
package utils.array
{
/**
* Creates a copy of the specified array.
*
* Note that the array returned is a new array but the items within the
* array are not copies of the items in the original array (but rather
* references to the same items)
*
* @param arr The array that will be copies
*
* @return A new array which contains the same items as the array passed
* in.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*/
public function copyArray(arr:Array):Array
{
return arr.slice();
}
}
================================================
FILE: src/utils/array/createUniqueCopy.as
================================================
package utils.array
{
/**
* Create a new array that only contains unique instances of objects
* in the specified array.
*
* Basically, this can be used to remove duplication object instances
* from an array
*
* @param arr The array which contains the values that will be used to
* create the new array that contains no duplicate values.
*
* @return A new array which only contains unique items from the specified
* array.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*/
public function createUniqueCopy(a:Array):Array
{
var newArray:Array = new Array();
var len:Number = a.length;
var item:Object;
for (var i:uint = 0; i < len; ++i)
{
item = a[i];
if (arrayContainsValue(newArray, item))
{
continue;
}
newArray.push(item);
}
return newArray;
}
}
================================================
FILE: src/utils/array/equals.as
================================================
package utils.array
{
/**
Determines if two Arrays contain the same objects at the same index.
@param first: First Array to compare to the <code>second</code>.
@param second: Second Array to compare to the <code>first</code>.
@return Returns <code>true</code> if Arrays are the same; otherwise <code>false</code>.
*/
public function equals(first:Array, second:Array):Boolean
{
var i:uint = first.length;
if (i != second.length)
return false;
while (i--)
if (first[i] != second[i])
return false;
return true;
}
}
================================================
FILE: src/utils/array/getHighestValue.as
================================================
package utils.array
{
/**
Finds the highest value in <code>inArray</code>.
@param inArray: Array composed only of numbers.
@return The highest value in <code>inArray</code>.
@example
<code>
var numberArray:Array = new Array(2, 1, 5, 4, 3);
trace("The highest value is: " + ArrayUtil.getHighestValue(numberArray));
</code>
*/
public function getHighestValue(inArray:Array):Number
{
return inArray[inArray.sort(16 | 8)[inArray.length - 1]];
}
}
================================================
FILE: src/utils/array/getIndexOfDifference.as
================================================
package utils.array
{
/**
Compares two Arrays and finds the first index where they differ.
@param first: First Array to compare to the <code>second</code>.
@param second: Second Array to compare to the <code>first</code>.
@param fromIndex: The location in the Arrays from which to start searching for a difference.
@return The first position/index where the Arrays differ; if Arrays are identical returns <code>-1</code>.
@example
<code>
var color:Array = new Array("Red", "Blue", "Green", "Indigo", "Violet");
var colorsAlt:Array = new Array("Red", "Blue", "Green", "Violet");
trace(ArrayUtil.getIndexOfDifference(color, colorsAlt)); // Traces 3
</code>
*/
public function getIndexOfDifference(first:Array, second:Array, fromIndex:uint = 0):int
{
var i:int = fromIndex - 1;
while (++i < first.length)
if (first[i] != second[i])
return i;
return -1;
}
}
================================================
FILE: src/utils/array/getItemByKey.as
================================================
package utils.array
{
/**
Returns the first element that matches <code>match</code> for the property <code>key</code>.
@param inArray: Array to search for an element with a <code>key</code> that matches <code>match</code>.
@param key: Name of the property to match.
@param match: Value to match against.
@return Returns matched <code>Object</code>; otherwise <code>null</code>.
*/
public function getItemByKey(inArray:Array, key:String, match:*):*
{
for each (var item:* in inArray)
if (item[key] == match)
return item;
return null;
}
}
================================================
FILE: src/utils/array/getItemByType.as
================================================
package utils.array
{
/**
Returns the first element that is compatible with a specific data type, clazz, or interface.
@param inArray: Array to search for an element of a specific type.
@param type: The type to compare the elements to.
@return Returns all the matched elements.
*/
public function getItemByType(inArray:Array, type:Class):*
{
for each (var item:* in inArray)
if (item is type)
return item;
return null;
}
}
================================================
FILE: src/utils/array/getItemsByKey.as
================================================
package utils.array
{
/**
Returns every element that matches <code>match</code> for the property <code>key</code>.
@param inArray: Array to search for object with <code>key</code> that matches <code>match</code>.
@param key: Name of the property to match.
@param match: Value to match against.
@return Returns all the matched elements.
*/
public function getItemsByKey(inArray:Array, key:String, match:*):Array
{
var t:Array = new Array();
for each (var item:* in inArray)
if (item[key] == match)
t.push(item);
return t;
}
}
================================================
FILE: src/utils/array/getItemsByType.as
================================================
package utils.array
{
/**
Returns every element that is compatible with a specific data type, clazz, or interface.
@param inArray: Array to search for elements of a specific type.
@param type: The type to compare the elements to.
@return Returns all the matched elements.
*/
public function getItemsByType(inArray:Array, type:Class):Array
{
var t:Array = new Array();
for each (var item:* in inArray)
if (item is type)
t.push(item);
return t;
}
}
================================================
FILE: src/utils/array/getLowestValue.as
================================================
package utils.array
{
/**
Finds the lowest value in <code>inArray</code>.
@param inArray: Array composed only of numbers.
@return The lowest value in <code>inArray</code>.
@example
<code>
var numberArray:Array = new Array(2, 1, 5, 4, 3);
trace("The lowest value is: " + ArrayUtil.getLowestValue(numberArray));
</code>
*/
public function getLowestValue(inArray:Array):Number
{
return inArray[inArray.sort(16 | 8)[0]];
}
}
================================================
FILE: src/utils/array/getRandomElement.as
================================================
package utils.array {
import utils.number.randomIntegerWithinRange;
/**
* Returns a random element from an array.
*/
public function getRandomElement(array:Array):* {
return array[randomIntegerWithinRange(0, array.length-1)];
}
}
================================================
FILE: src/utils/array/randomize.as
================================================
package utils.array
{
import utils.number.randomIntegerWithinRange;
/**
Creates new Array composed of passed Array's items in a random order.
@param inArray: Array to create copy of, and randomize.
@return A new Array composed of passed Array's items in a random order.
@example
<code>
var numberArray:Array = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
trace(ArrayUtil.randomize(numberArray));
</code>
*/
public function randomize(inArray:Array):Array
{
var t:Array = new Array();
var r:Array = inArray.sort(
function(a:*, b:*):int
{
return randomIntegerWithinRange(0, 1) ? 1 : -1;
}
, Array.RETURNINDEXEDARRAY);
var i:int = -1;
while (++i < inArray.length)
t.push(inArray[r[i]]);
return t;
}
}
================================================
FILE: src/utils/array/removeDuplicates.as
================================================
package utils.array
{
/**
Creates new Array composed of only the non-identical elements of passed Array.
@param inArray: Array to remove equivalent items.
@return A new Array composed of only unique elements.
@example
<code>
var numberArray:Array = new Array(1, 2, 3, 4, 4, 4, 4, 5);
trace(ArrayUtil.removeDuplicates(numberArray));
</code>
*/
public function removeDuplicates(inArray:Array):Array
{
return inArray.filter(
function(e:*, i:int, inArray:Array):Boolean
{
return (i == 0) ? true : inArray.lastIndexOf(e, i - 1) == -1;
});
}
}
================================================
FILE: src/utils/array/removeItem.as
================================================
package utils.array
{
/**
Modifies original Array by removing all items that are identical to the specified item.
@param tarArray: Array to remove passed <code>item</code>.
@param item: Element to remove.
@return The amount of removed elements that matched <code>item</code>, if none found returns <code>0</code>.
@example
<code>
var numberArray:Array = new Array(1, 2, 3, 7, 7, 7, 4, 5);
trace("Removed " + ArrayUtil.removeItem(numberArray, 7) + " items.");
trace(numberArray);
</code>
*/
public function removeItem(tarArray:Array, item:*):uint
{
var i:int = tarArray.indexOf(item);
var f:uint = 0;
while (i != -1)
{
tarArray.splice(i, 1);
i = tarArray.indexOf(item, i);
f++;
}
return f;
}
}
================================================
FILE: src/utils/array/removeItems.as
================================================
package utils.array
{
/**
Removes only the specified items in an Array.
@param tarArray: Array to remove specified items from.
@param items: Array of elements to remove.
@return Returns <code>true</code> if the Array was changed as a result of the call; otherwise <code>false</code>.
@example
<code>
var numberArray:Array = new Array(1, 2, 3, 7, 7, 7, 4, 5);
ArrayUtil.removeItems(numberArray, new Array(1, 3, 7, 5));
trace(numberArray);
</code>
*/
public function removeItems(tarArray:Array, items:Array):Boolean
{
var removed:Boolean = false;
var l:uint = tarArray.length;
while (l--)
{
if (items.indexOf(tarArray[l]) > -1)
{
tarArray.splice(l, 1);
removed = true;
}
}
return removed;
}
}
================================================
FILE: src/utils/array/removeValueFromArray.as
================================================
package utils.array {
/**
* Remove all instances of the specified value from the array,
*
* @param arr The array from which the value will be removed
*
* @param value The object that will be removed from the array.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*/
public function removeValueFromArray(arr:Array, value:Object):void {
var len:uint = arr.length;
for(var i:Number = len; i > -1; i--) {
if(arr[i] == value) {
arr.splice(i, 1);
}
}
}
}
================================================
FILE: src/utils/array/retainItems.as
================================================
package utils.array
{
/**
Retains only the specified items in an Array.
@param tarArray: Array to remove non specified items from.
@param items: Array of elements to keep.
@return Returns <code>true</code> if the Array was changed as a result of the call; otherwise <code>false</code>.
@example
<code>
var numberArray:Array = new Array(1, 2, 3, 7, 7, 7, 4, 5);
ArrayUtil.retainItems(numberArray, new Array(2, 4));
trace(numberArray);
</code>
*/
public function retainItems(tarArray:Array, items:Array):Boolean
{
var removed:Boolean = false;
var l:uint = tarArray.length;
while (l--)
{
if (items.indexOf(tarArray[l]) == -1)
{
tarArray.splice(l, 1);
removed = true;
}
}
return removed;
}
}
================================================
FILE: src/utils/array/sum.as
================================================
package utils.array
{
/**
Adds all items in <code>inArray</code> and returns the value.
@param inArray: Array composed only of numbers.
@return The total of all numbers in <code>inArray</code> added.
@example
<code>
var numberArray:Array = new Array(2, 3);
trace("Total is: " + ArrayUtil.sum(numberArray));
</code>
*/
public function sum(inArray:Array):Number
{
var t:Number = 0;
var l:uint = inArray.length;
while (l--)
t += inArray[l];
return t;
}
}
================================================
FILE: src/utils/assert/assertArrayContains.as
================================================
package utils.assert
{
/**
* Assert that the array contains the passed in item.
*/
public function assertArrayContains(array:Array, item:*, message:String = ""):void
{
if (array.indexOf(item) == -1)
{
if (message == null || message.length == 0)
{
message = "[Assertion failed] - this Array argument does not contain the item '" + item + "'";
}
throw new Error(message);
}
}
}
================================================
FILE: src/utils/assert/assertArrayItemsTypeOf.as
================================================
package utils.assert
{
/**
* Assert that all items in the array are of the given type.
*
* @param array the array to check
* @param type the type of the array items
* @param message the error message to use if the assertion fails
*/
public function assertArrayItemsTypeOf(array:Array, type:Class, message:String = ""):void
{
for each (var item:* in array)
{
if (!(item is type))
{
if (message == null || message.length == 0)
{
message = "[Assertion failed] - this Array must have items of type '" + type + "'";
}
throw new Error(message);
}
}
}
}
================================================
FILE: src/utils/assert/assertDictionaryKeysTypeOf.as
================================================
package utils.assert
{
import flash.utils.Dictionary;
/**
* Assert that the given Dictionary contains only keys of the given type.
*/
public function assertDictionaryKeysTypeOf(dictionary:Dictionary, type:Class, message:String = ""):void
{
for (var key:Object in dictionary)
{
if (!(key is type))
{
if (message == null || message.length == 0)
{
message = "[Assertion failed] - this Dictionary argument must have keys of type '" + type + "'";
}
throw new Error(message);
}
}
}
}
================================================
FILE: src/utils/assert/assertHasText.as
================================================
package utils.assert
{
import utils.validation.isBlank;
/**
* Assert that the given String has valid text content; that is, it must not
* be <code>null</code> and must contain at least one non-whitespace character.
*
* @param text the String to check
* @param message the exception message to use if the assertion fails
* @see StringUtils#hasText
*/
public function assertHasText(string:String, message:String = ""):void
{
if (isBlank(string))
{
if (message == null || message.length == 0)
{
message = "[Assertion failed] - this String argument must have text; it must not be <code>null</code>, empty, or blank";
}
throw new Error(message);
}
}
}
================================================
FILE: src/utils/assert/assertInstanceOf.as
================================================
package utils.assert
{
/**
* Assert that an object is an instance of a certain type..
* <pre class="code">Assert.instanceOf(value, type, "The value must be an instance of 'type'");</pre>
* @param object the object to check
* @param message the error message to use if the assertion fails
* @throws org.as3commons.lang.IllegalArgumentError if the object is not an instance of the given type
*/
public function assertInstanceOf(object:*, type:Class, message:String = ""):void
{
if (!(object is type))
{
if (message == null || message.length == 0)
{
message = "[Assertion failed] - this argument is not of type '" + type + "'";
}
throw new Error(message);
}
}
}
================================================
FILE: src/utils/assert/assertIsTrue.as
================================================
package utils.assert
{
public function assertIsTrue(expression:Boolean, message:String = ""):void
{
if (!expression)
{
if (message == null || message.length == 0)
{
message = "[Assertion failed] - this expression must be true";
}
throw new Error(message);
}
}
}
================================================
FILE: src/utils/assert/assertNotNull.as
================================================
package utils.assert
{
/**
* Assert that an object is <code>null</code>.
* <pre class="code">Assert.isNull(value, "The value must be null");</pre>
* @param object the object to check
* @param message the error message to use if the assertion fails
* @throws org.as3commons.lang.IllegalArgumentError if the object is not <code>null</code>
*/
public function assertNotNull(object:Object, message:String = ""):void
{
if (object == null)
{
if (message == null || message.length == 0)
{
message = "[Assertion failed] - this argument is required; it must not null";
}
throw new Error(message);
}
}
}
================================================
FILE: src/utils/assert/assertState.as
================================================
package utils.assert
{
/**
* Assert a boolean expression to be true. If false, an IllegalStateError is thrown.
* @param expression a boolean expression
* @param the error message if the assertion fails
*/
public function assertState(expression:Boolean, message:String = ""):void
{
if (!expression)
{
if (message == null || message.length == 0)
{
message = "[Assertion failed] - this state invariant must be true";
}
throw new Error(message);
}
}
}
================================================
FILE: src/utils/boolean/randomBoolean.as
================================================
package utils.boolean
{
/**
* Randomly returns either true or false.
*
* @author Mims Wright
*/
public function randomBoolean():Boolean
{
return randomChance(0.5);
}
}
================================================
FILE: src/utils/boolean/randomChance.as
================================================
package utils.boolean
{
/**
* Randomly returns true "percent"% of the time (where percent is a decimal between 0.0 and 1.0).
*
* @author Mims Wright
*/
public function randomChance(percent:Number):Boolean
{
return Math.random() < percent;
}
}
================================================
FILE: src/utils/capabilities/getPlayerInfo.as
================================================
package utils.capabilities
{
import flash.system.Capabilities;
/**
* Returns a player and environment info string.
*/
public function getPlayerInfo():String
{
var debugger:String = (Capabilities.isDebugger) ? ' / Debugger' : '';
var info:String =
String("Flash Platform: " + Capabilities.version + " / " + Capabilities.playerType + debugger + " / " + Capabilities.os + " / " + Capabilities.screenResolutionX + "x" + Capabilities.screenResolutionY);
return info;
}
}
================================================
FILE: src/utils/capabilities/isAirApplication.as
================================================
package utils.capabilities {
import flash.system.Capabilities;
/**
* Determines if the runtime environment is an Air application.
* @return true if the runtime environment is an Air application
* @author Aaron Clinger
* @author Shane McCartney
* @author David Nelson
*/
public function isAirApplication():Boolean {
return Capabilities.playerType == "Desktop";
}
}
================================================
FILE: src/utils/capabilities/isIDE.as
================================================
package utils.capabilities {
import flash.system.Capabilities;
/**
* Determines if the SWF is running in the IDE.
* @return true if SWF is running in the Flash Player version used by the external player or test movie mode
* @author Aaron Clinger
* @author Shane McCartney
* @author David Nelson
*/
public function isIDE():Boolean {
return Capabilities.playerType == "External";
}
}
================================================
FILE: src/utils/capabilities/isMac.as
================================================
package utils.capabilities
{
import flash.system.Capabilities;
/**
* Indicates whether the running OS is a Mac
* @return
*/
public function isMac():Boolean
{
return Capabilities.os.toLowerCase().indexOf("mac os") != -1;
}
}
================================================
FILE: src/utils/capabilities/isPC.as
================================================
package utils.capabilities
{
import flash.system.Capabilities;
/**
* Indicates whether the running OS is a PC
* @return
*/
public function isPC():Boolean
{
return Capabilities.os.toLowerCase().indexOf("mac os") == -1;
}
}
================================================
FILE: src/utils/capabilities/isPlugin.as
================================================
package utils.capabilities {
import flash.system.Capabilities;
/**
* Determines if the SWF is running in a browser plug-in.
* @return true if SWF is running in the Flash Player browser plug-in
* @author Aaron Clinger
* @author Shane McCartney
* @author David Nelson
*/
public function isPlugin():Boolean {
return Capabilities.playerType == "PlugIn" || Capabilities.playerType == "ActiveX";
}
}
================================================
FILE: src/utils/capabilities/isStandAlone.as
================================================
package utils.capabilities {
import flash.system.Capabilities;
/**
* Determines if the SWF is running in the StandAlone player.
* @return true if SWF is running in the Flash StandAlone Player
* @author Aaron Clinger
* @author Shane McCartney
* @author David Nelson
*/
public function isStandAlone():Boolean {
return Capabilities.playerType == "StandAlone";
}
}
================================================
FILE: src/utils/capabilities/isWeb.as
================================================
package utils.capabilities {
import flash.display.DisplayObject;
/**
* Determines if the SWF is being served on the internet.
* Example code:
* <pre>
* trace(isWeb(_root));
* </pre>
* @param location DisplayObject to get location of
* @return true if SWF is being served on the internet
* @author Aaron Clinger
* @author Shane McCartney
* @author David Nelson
*/
public function isWeb(location:DisplayObject):Boolean {
return location.loaderInfo.url.substr(0, 4) == "http";
}
}
================================================
FILE: src/utils/color/HSLtoHSV.as
================================================
package utils.color
{
/**
* Convert HSL to HSV using RGB conversions: color preservation may be dubious.
*/
public function HSLtoHSV(hue:Number, luminance:Number, saturation:Number):Object
{
var rgbVal:Object = HSLtoRGB(hue, luminance, saturation);
return RGBtoHSV(rgbVal.r, rgbVal.g, rgbVal.b);
}
}
================================================
FILE: src/utils/color/HSLtoRGB.as
================================================
package utils.color
{
/**
* Convert HSL values to RGB values.
* @param hue 0 to 360.
* @param luminance 0 to 1.
* @param saturation 0 to 1.
* @return Object with R,G,B values on 0 to 1 scale.
*/
public function HSLtoRGB(hue:Number, luminance:Number, saturation:Number):Object
{
var delta:Number;
if (luminance < 0.5)
{
delta = saturation * luminance;
}
else
{
delta = saturation * (1 - luminance);
}
return HueToRGB(luminance - delta, luminance + delta, hue);
}
}
================================================
FILE: src/utils/color/HSVtoHSL.as
================================================
package utils.color
{
/**
* Convert HSV to HLS using RGB conversions: color preservation may be dubious.
*/
public function HSVtoHSL(hue:Number, saturation:Number, value:Number):Object
{
var rgbVal:Object = HSVtoRGB(hue, saturation, value);
return RGBtoHSL(rgbVal.r, rgbVal.g, rgbVal.b);
}
}
================================================
FILE: src/utils/color/HSVtoRGB.as
================================================
package utils.color
{
/**
* Convert HSV values to RGB values.
* @param hue on 0 to 360 scale.
* @param saturation on 0 to 1 scale.
* @param value on 0 to 1 scale.
* @return Object with R,G,B values on 0 to 1 scale.
*/
public function HSVtoRGB(hue:Number, saturation:Number, value:Number):Object
{
var min:Number = (1 - saturation) * value;
return HueToRGB(min, value, hue);
}
}
================================================
FILE: src/utils/color/HueToRGB.as
================================================
package utils.color
{
/**
* Convert hue to RGB values using a linear transformation.
* @param min of R,G,B.
* @param max of R,G,B.
* @param hue value angle hue.
* @return Object with R,G,B properties on 0-1 scale.
*/
public function HueToRGB(min:Number, max:Number, hue:Number):Object
{
const HUE_MAX:uint = 360;
var mu:Number, md:Number, F:Number, n:Number;
while (hue < 0)
{
hue += HUE_MAX;
}
n = Math.floor(hue / 60);
F = (hue - n * 60) / 60;
n %= 6;
mu = min + ((max - min) * F);
md = max - ((max - min) * F);
switch (n)
{
case 0:
return { r: max, g: mu, b: min };
case 1:
return { r: md, g: max, b: min };
case 2:
return { r: min, g: max, b: mu };
case 3:
return { r: min, g: md, b: max };
case 4:
return { r: mu, g: min, b: max };
case 5:
return { r: max, g: min, b: md };
}
return null;
}
}
================================================
FILE: src/utils/color/RGBToHue.as
================================================
package utils.color
{
import utils.range.center;
/**
* Convert RGB values to a hue using a linear transformation.
* @param red value on 0 to 1 scale.
* @param green value on 0 to 1 scale.
* @param blue value on 0 to 1 scale.
* @return hue degree between 0 and 360.
*/
public function RGBToHue(red:Number, green:Number, blue:Number):uint
{
var f:Number, min:Number, mid:Number, max:Number, n:Number;
max = Math.max(red, Math.max(green, blue));
min = Math.min(red, Math.min(green, blue));
// achromatic case
if (max - min == 0)
{
return 0;
}
mid = center(red, green, blue);
// using this loop to avoid super-ugly nested ifs
while (true)
{
if (red == max)
{
if (blue == min)
n = 0;
else
n = 5;
break;
}
if (green == max)
{
if (blue == min)
n = 1;
else
n = 2;
break;
}
if (red == min)
n = 3;
else
n = 4;
break;
}
if ((n % 2) == 0)
{
f = mid - min;
}
else
{
f = max - mid;
}
f = f / (max - min);
return 60 * (n + f);
}
}
================================================
FILE: src/utils/color/RGBtoHSL.as
================================================
package utils.color {
/**
* Convert an RGB Hexadecimal value to HSL values
* @param red 0 - 1 scale.
* @param green 0 - 1 scale.
* @param blue 0 - 1 scale.
* @return Object with h (hue), l (lightness), s (saturation) values:<ul>
* <li><code>h</code> on 0 - 360 scale.</li>
* <li><code>l</code> on 0 - 255 scale.</li>
* <li><code>s</code> on 0 - 1 scale.</li></ul>
*/
public function RGBtoHSL(red:Number, green:Number, blue:Number):Object {
var min:Number, max:Number, delta:Number, l:Number, s:Number, h:Number = 0;
max = Math.max(red, Math.max(green, blue));
min = Math.min(red, Math.min(green, blue));
//l = (min + max) / 2;
l = (min + max) * 0.5;
// L
if(l == 0) {
return { h: h, l: 0, s: 1 };
}
//delta = (max - min) / 2;
delta = (max - min) * 0.5;
if(l < 0.5) {
// S
s = delta / l;
}
else {
s = delta / (1 - l);
}
// H
h = RGBToHue(red, green, blue);
return { h: h, l: l, s: s };
}
}
================================================
FILE: src/utils/color/RGBtoHSV.as
================================================
package utils.color
{
/**
* Convert RGB values to HSV values.
* @param red 0 to 1 scale.
* @param green 0 to 1 scale.
* @param blue 0 to 1 scale.
* @return Object with H,S,V values:<ul>
* <li>h - on 0 to 360 scale</li>
* <li>s - on 0 to 1 scale</li>
* <li>v - on 0 to 1 scale</li></ul>
*/
public function RGBtoHSV(red:Number, green:Number, blue:Number):Object
{
var min:Number, max:Number, s:Number, v:Number, h:Number = 0;
max = Math.max(red, Math.max(green, blue));
min = Math.min(red, Math.min(green, blue));
if (max == 0)
{
return { h: 0, s: 0, v: 0 };
}
v = max;
s = (max - min) / max;
h = RGBToHue(red, green, blue);
return { h: h, s: s, v: v };
}
}
================================================
FILE: src/utils/color/averageBlue.as
================================================
package utils.color
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
* Sample & average the <i>Blue</i> (RGB) value from a display object or one of its region.
*
* @param src The DisplayObject
* @param accuracy Percentage of pixels to sample when averaging.
* @param region to sample from [Default: null = entire src object].
* @return the sampled average <i>blue</i> value on a scale of 0-255.
*/
public function averageBlue(src:DisplayObject, accuracy:Number = 0.01, region:Rectangle = null):int
{
return averageColorProperty(src, region, accuracy, 'b');
}
}
================================================
FILE: src/utils/color/averageColorProperty.as
================================================
package utils.color
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
* @private
*
* Sample & average a colorspace value (RGB or HSL) value from a display object or one of its region.
* @param src of the display object.
* @param region to sample from [Default: null = entire src object].
* @param accuracy percentage of pixels to sample when averaging.
* @colorspace to be sampled. Valid arguments are <code>'r', 'g', 'b', 'h', 's', 'l', 'v'</code>.
* @return the sampled average value requested from the colorspace.
*/
public function averageColorProperty(src:DisplayObject, region:Rectangle = null, accuracy:Number = 0.01, colorspace:String = 'l'):Number
{
if (!region)
{
region = new Rectangle(0, 0, src.width, src.height);
}
var offset:int = 1 / accuracy;
var total:int;
var count:int;
// loop thru x/y pixels by offset
for (var i:int = region.x; i < (region.x + region.width); i += offset)
{
for (var j:int = region.y; j < (region.y + region.height); j += offset)
{
var hex:uint = getColorFromDisplayObject(src, i, j);
var obj:Object = getRGB(hex);
if (colorspace == "h" || colorspace == "s" || colorspace == "l")
{
var hsl:Object = RGBtoHSL(obj.r, obj.g, obj.b);
obj = hsl;
}
if (colorspace == "v")
{
var hsv:Object = RGBtoHSV(obj.r, obj.g, obj.b);
obj = hsv;
}
total += obj[colorspace];
count++;
//trace( "colorspace: '" + colorspace + "' = " + obj[colorspace] );
}
}
// return the average value
return total / count;
}
}
================================================
FILE: src/utils/color/averageGreen.as
================================================
package utils.color
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
* Sample & average the <i>Green</i> (RGB) value from a display object or one of its region.
*
* @param src The DisplayObject
* @param accuracy Percentage of pixels to sample when averaging.
* @param region to sample from [Default: null = entire src object].
* @return the sampled average <i>green</i> value on a scale of 0-255.
*/
public function averageGreen(src:DisplayObject, accuracy:Number = 0.01, region:Rectangle = null):int
{
return averageColorProperty(src, region, accuracy, 'g');
}
}
================================================
FILE: src/utils/color/averageHue.as
================================================
package utils.color
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
* Sample & average the <i>Hue</i> (HSL) value from a display object or one of its region.
*
* @param src The DisplayObject
* @param accuracy percentage of pixels to sample when averaging.
* @param region to sample from [Default: null = entire src object].
* @return the sampled average <i>hue</i> value on a scale of 0-360.
*/
public function averageHue(src:DisplayObject, accuracy:Number = 0.01, region:Rectangle = null):int
{
return averageColorProperty(src, region, accuracy, 'h');
}
}
================================================
FILE: src/utils/color/averageLightness.as
================================================
package utils.color
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
* Sample & average the <i>Lightness</i> (HSL) value from a display object or one of its region.
*
* @param src The DisplayObject
* @param accuracy percentage of pixels to sample when averaging.
* @param region to sample from [Default: null = entire src object].
* @return the sampled average <i>lightness</i> value on a scale of 0-255.
*/
public function averageLightness(src:DisplayObject, accuracy:Number = 0.01, region:Rectangle = null):int
{
return averageColorProperty(src, region, accuracy, 'l');
}
}
================================================
FILE: src/utils/color/averageRed.as
================================================
package utils.color
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
* Sample & average the <i>Red</i> (RGB) value from a display object or one of its region.
*
* @param src The DisplayObject.
* @param accuracy Percentage of pixels to sample when averaging.
* @param region to sample from [Default: null = entire src object].
* @return the sampled average <i>red</i> value on a scale of 0-255.
*/
public function averageRed(src:DisplayObject, accuracy:Number = 0.01, region:Rectangle = null):int
{
return averageColorProperty(src, region, accuracy, 'r');
}
}
================================================
FILE: src/utils/color/averageSaturation.as
================================================
package utils.color
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
* Sample & average the <i>Saturation</i> (HSL) value from a display object or one of its region.
*
* @param src The DisplayObject.
* @param accuracy percentage of pixels to sample when averaging.
* @param region to sample from [Default: null = entire src object].
* @return the sampled average <i>saturation</i> value on a scale of 0-1.
*/
public function averageSaturation(src:DisplayObject, accuracy:Number = 0.01, region:Rectangle = null):Number
{
return averageColorProperty(src, region, accuracy, 's');
}
}
================================================
FILE: src/utils/color/averageValue.as
================================================
package utils.color
{
import flash.display.DisplayObject;
import flash.geom.Rectangle;
/**
* Sample & average the <i>Value</i> (HSV) value from a display object or one of its region.
*
* @param src The DisplayObject
* @param accuracy percentage of pixels to sample when averaging.
* @param region to sample from [Default: null = entire src object].
* @return the sampled average <i>lightness</i> value on a scale of 0-1.
*/
public function averageValue(src:DisplayObject, accuracy:Number = 0.01, region:Rectangle = null):Number
{
return averageColorProperty(src, region, accuracy, 'v');
}
}
================================================
FILE: src/utils/color/changeContrast.as
================================================
package utils.color {
import utils.number.clamp;
/**
* Change the contrast of a hexadecimal Number by a certain increment
* @param hex color value to shift contrast on
* @param inc increment value to shift
* @return new hex color value
*/
public function changeContrast(hex:Number, inc:Number):Number {
var o:Object = getRGB(hex);
o.r = clamp(o.r + inc, 0, 255);
o.g = clamp(o.g + inc, 0, 255);
o.b = clamp(o.b + inc, 0, 255);
return toRGBComponents(o.r, o.g, o.b);
}
}
================================================
FILE: src/utils/color/getARGB.as
================================================
package utils.color
{
/**
Converts a 32-bit ARGB color value into an ARGB object.
@param color: The 32-bit ARGB color value.
@return Returns an object with the properties a, r, g, and b defined.
@example
<listing version="3.0">
var myRGB:Object = ColorUtil.getARGB(0xCCFF00FF);
trace("Alpha = " + myRGB.a);
trace("Red = " + myRGB.r);
trace("Green = " + myRGB.g);
trace("Blue = " + myRGB.b);
</listing>
*/
public function getARGB(color:uint):Object
{
var c:Object = {};
c.a = color >> 24 & 0xFF;
c.r = color >> 16 & 0xFF;
c.g = color >> 8 & 0xFF;
c.b = color & 0xFF;
return c;
}
}
================================================
FILE: src/utils/color/getColor.as
================================================
package utils.color
{
/**
Converts a series of individual RGB(A) values to a 32-bit ARGB color value.
@param r A uint from 0 to 255 representing the red color value.
@param g A uint from 0 to 255 representing the green color value.
@param b A uint from 0 to 255 representing the blue color value.
@param a A uint from 0 to 255 representing the alpha value. Default is <code>255</code>.
@return Returns a hexidecimal color as a String.
@example
<listing version="3.0">
var hexColor : String = ColorUtil.getHexStringFromARGB(128, 255, 0, 255);
trace(hexColor); // Traces 80FF00FF
</listing>
*/
public function getColor(r:uint, g:uint, b:uint, a:uint = 255):uint
{
return (a << 24) | (r << 16) | (g << 8) | b;
}
}
================================================
FILE: src/utils/color/getColorFromDisplayObject.as
================================================
package utils.color
{
import flash.display.BitmapData;
import flash.display.DisplayObject;
import utils.number.clamp;
/**
* Return the (A)RGB <i>hexadecimal</i> color value of a DisplayObject.
* @param src of the display object.
* @param x position to sample.
* @param y position to sample.
* @param getAlpha if true return is RGBA, else RGB.
*/
public function getColorFromDisplayObject(src:DisplayObject, x:uint = 0, y:uint = 0, getAlpha:Boolean = false):uint
{
const MAX_SIZE_SAFE:int = 2880;
var w:Number = clamp(src.width, 1, MAX_SIZE_SAFE);
var h:Number = clamp(src.height, 1, MAX_SIZE_SAFE);
var bmp:BitmapData = new BitmapData(w, h);
bmp.lock();
bmp.draw(src);
var color:uint = (!getAlpha) ? bmp.getPixel(int(x), int(y)) : bmp.getPixel32(int(x), int(y));
bmp.unlock();
bmp.dispose();
return color;
}
}
================================================
FILE: src/utils/color/getHexStringFromARGB.as
================================================
package utils.color {
/**
Converts a 32-bit ARGB color value into a hexadecimal String representation.
@param a A uint from 0 to 255 representing the alpha value.
@param r A uint from 0 to 255 representing the red color value.
@param g A uint from 0 to 255 representing the green color value.
@param b A uint from 0 to 255 representing the blue color value.
@return Returns a hexadecimal color as a String.
@example
<code>
var hexColor : String = ColorUtil.getHexStringFromARGB(128, 255, 0, 255);
trace(hexColor); // Traces 80FF00FF
</code>
*/
public function getHexStringFromARGB(a:uint, r:uint, g:uint, b:uint):String {
var aa:String = a.toString(16);
var rr:String = r.toString(16);
var gg:String = g.toString(16);
var bb:String = b.toString(16);
aa = (aa.length == 1) ? '0' + aa : aa;
rr = (rr.length == 1) ? '0' + rr : rr;
gg = (gg.length == 1) ? '0' + gg : gg;
bb = (bb.length == 1) ? '0' + bb : bb;
return (aa + rr + gg + bb).toUpperCase();
}
}
================================================
FILE: src/utils/color/getHexStringFromRGB.as
================================================
package utils.color {
/**
Converts an RGB color value into a hexadecimal String representation.
@param r A uint from 0 to 255 representing the red color value.
@param g A uint from 0 to 255 representing the green color value.
@param b A uint from 0 to 255 representing the blue color value.
@return Returns a hexadecimal color as a String.
@example
<code>
var hexColor : String = ColorUtil.getHexStringFromRGB(255, 0, 255);
trace(hexColor); // Traces FF00FF
</code>
*/
public function getHexStringFromRGB(r:uint, g:uint, b:uint):String {
var rr:String = r.toString(16);
var gg:String = g.toString(16);
var bb:String = b.toString(16);
rr = (rr.length == 1) ? '0' + rr : rr;
gg = (gg.length == 1) ? '0' + gg : gg;
bb = (bb.length == 1) ? '0' + bb : bb;
return (rr + gg + bb).toUpperCase();
}
}
================================================
FILE: src/utils/color/getRGB.as
================================================
package utils.color
{
/**
Converts a 24-bit RGB color value into an RGB object.
@param color: The 24-bit RGB color value.
@return Returns an object with the properties r, g, and b defined.
@example
<code>
var myRGB:Object = ColorUtil.getRGB(0xFF00FF);
trace("Red = " + myRGB.r);
trace("Green = " + myRGB.g);
trace("Blue = " + myRGB.b);
</code>
*/
public function getRGB(color:uint):Object
{
var c:Object = {};
c.r = color >> 16 & 0xFF;
c.g = color >> 8 & 0xFF;
c.b = color & 0xFF;
return c;
}
}
================================================
FILE: src/utils/color/getTransform.as
================================================
package utils.color
{
import flash.display.DisplayObject;
import flash.geom.ColorTransform;
/**
* Returns the transform value set by the last setTransform() call.
* @return An object containing the current offset and percentage values for the color.
*/
public function getTransform(src:DisplayObject):Object
{
var ct:ColorTransform = src.transform.colorTransform;
return { ra: ct.redMultiplier * 100, rb: ct.redOffset, ga: ct.greenMultiplier * 100, gb: ct.greenOffset, ba: ct.blueMultiplier * 100, bb: ct.blueOffset, aa: ct.alphaMultiplier * 100,
ab: ct.alphaOffset };
}
}
================================================
FILE: src/utils/color/interpolateColor.as
================================================
package utils.color
{
import flash.geom.ColorTransform;
import utils.math.Percent;
import utils.number.interpolate;
/**
Interpolates (tints) between two colors.
@param begin: The start color.
@param end: The finish color.
@param amount: The level of interpolation between the two colors.
@return The new interpolated color.
@usage
<code>
var myColor:ColorTransform = new ColorTransform();
myColor.color = 0xFF0000;
var box:Sprite = new Sprite();
box.graphics.beginFill(0x0000FF);
box.graphics.drawRect(10, 10, 250, 250);
box.graphics.endFill();
box.transform.colorTransform = ColorUtil.interpolateColor(new ColorTransform(), myColor, new Percent(0.5));
this.addChild(box);
</code>
*/
public function interpolateColor(begin:ColorTransform, end:ColorTransform, amount:Percent):ColorTransform
{
var interpolation:ColorTransform = new ColorTransform();
interpolation.redMultiplier = interpolate(amount, begin.redMultiplier, end.redMultiplier);
interpolation.greenMultiplier = interpolate(amount, begin.greenMultiplier, end.greenMultiplier);
interpolation.blueMultiplier = interpolate(amount, begin.blueMultiplier, end.blueMultiplier);
interpolation.alphaMultiplier = interpolate(amount, begin.alphaMultiplier, end.alphaMultiplier);
interpolation.redOffset = interpolate(amount, begin.redOffset, end.redOffset);
interpolation.greenOffset = interpolate(amount, begin.greenOffset, end.greenOffset);
interpolation.blueOffset = interpolate(amount, begin.blueOffset, end.blueOffset);
interpolation.alphaOffset = interpolate(amount, begin.alphaOffset, end.alphaOffset);
return interpolation;
}
}
================================================
FILE: src/utils/color/invertColor.as
================================================
package utils.color
{
import flash.display.DisplayObject;
/**
* Inverts the color of the DisplayObject.
*/
public function invertColor(src:DisplayObject):void
{
var t:Object = getTransform(src);
setTransform(src, {
ra: -t['ra'], ga: -t['ga'], ba: -t['ba'], rb: 255 - t['rb'], gb: 255 - t['gb'], bb: 255 - t['bb']
});
}
}
================================================
FILE: src/utils/color/randomColor.as
================================================
package utils.color
{
/**
* Returns a random color between 0x000000 and 0xFFFFFF
*
* @author Mims Wright
*/
public function randomColor():uint {
return uint(Math.random() * 0xFFFFFF);
}
}
================================================
FILE: src/utils/color/resetColor.as
================================================
package utils.color
{
import flash.display.DisplayObject;
/**
* Reset the color of the DisplayObject to its original view (pre-ColorTransformed).
*/
public function resetColor(src:DisplayObject):void
{
setTransform(src, { ra: 100, ga: 100, ba: 100, rb: 0, gb: 0, bb: 0 });
}
}
================================================
FILE: src/utils/color/setARGB.as
================================================
package utils.color
{
public function setARGB(a:Number, r:Number, g:Number, b:Number):uint
{
var argb:uint = 0;
argb += (a << 24);
argb += (r << 16);
argb += (g << 8);
argb += (b);
return argb;
}
}
================================================
FILE: src/utils/color/setColor.as
================================================
package utils.color
{
import flash.display.DisplayObject;
import flash.geom.ColorTransform;
/**
* Set the (A)RGB <i>hexadecimal</i> color value of a DisplayObject using ColorTransform.
*/
public function setColor(src:DisplayObject, hex:uint):void
{
var ct:ColorTransform = src.transform.colorTransform;
ct.color = hex;
src.transform.colorTransform = ct;
}
}
================================================
FILE: src/utils/color/setTransform.as
================================================
package utils.color
{
import flash.display.DisplayObject;
import flash.geom.ColorTransform;
/**
* Set ColorTransform information for a DisplayObject.
*
* <p>The colorTransformObject parameter is a generic object that you create from the new Object constructor. It has parameters specifying the percentage and
* offset values for the red, green, blue, and alpha (transparency) components of a color, entered in the format 0xRRGGBBAA.</p>
*
* @param transformObject An object created with the new Object constructor. This instance of the Object class must have the following properties
* that specify color transform values: ra, rb, ga, gb, ba, bb, aa, ab. These properties are explained in the above summary for the setTransform() method.
*/
public function setTransform(src:DisplayObject, transformObject:Object):void
{
var t:Object = { ra: 100, rb: 0, ga: 100, gb: 0, ba: 100, bb: 0, aa: 100, ab: 0 };
for (var p:String in transformObject)
{
t[p] = transformObject[p];
}
var ct:ColorTransform = new ColorTransform(t['ra'] * 0.01, t['ga'] * 0.01, t['ba'] * 0.01, t['aa'] * 0.01, t['rb'], t['gb'], t['bb'], t['ab']);
src.transform.colorTransform = ct;
}
}
================================================
FILE: src/utils/color/toColor.as
================================================
package utils.color
{
/**
* Parse a String representation of a color (hex or html) to uint.
*/
public function toColor(str:String):uint
{
if (str.substr(0, 2) == '0x')
{
str = str.substr(2);
}
else if (str.substr(0, 1) == '#')
{
str = str.substr(1);
}
return parseInt(str, 16);
}
}
================================================
FILE: src/utils/color/toGrayscale.as
================================================
package utils.color
{
public function toGrayscale(hex:uint):uint
{
var color:Object = getARGB(hex);
var c:Number = 0;
c += color.r * .3;
c += color.g * .59;
c += color.b * .11;
color.r = color.g = color.b = c;
return setARGB(color.a, color.r, color.g, color.b);
}
}
================================================
FILE: src/utils/color/toHTML.as
================================================
package utils.color {
/**
* Convert a hexadecimal number to a string representation with HTML notation: <code>#rrggbb</code>.
*/
public function toHTML(hex:uint):String {
return "#" + (hex.toString(16)).toUpperCase();
}
}
================================================
FILE: src/utils/color/toHexString.as
================================================
package utils.color {
/**
* Convert a hexadecimal number to a string representation with ECMAScript notation: <code>0xrrggbb</code>.
*/
public function toHexString(hex:uint):String {
return "0x" + (hex.toString(16)).toUpperCase();
}
}
================================================
FILE: src/utils/color/toRGBComponents.as
================================================
package utils.color {
/**
* Convert individual R,G,B values to a hexadecimal value.
*/
public function toRGBComponents(r:uint, g:uint, b:uint):uint {
var hex:uint = 0;
hex += (r << 16);
hex += (g << 8);
hex += (b);
return hex;
}
}
================================================
FILE: src/utils/conversion/bitsToBytes.as
================================================
package utils.conversion
{
/**
Converts bits to bytes.
@param bits: The number of bits.
@return Returns the number of bytes.
*/
public function bitsToBytes(bits:Number):Number
{
return bits / 8;
}
}
================================================
FILE: src/utils/conversion/bitsToKilobits.as
================================================
package utils.conversion
{
/**
Converts bits to kilobits.
@param bits: The number of bits.
@return Returns the number of kilobits.
*/
public function bitsToKilobits(bits:Number):Number
{
return bits / 1024;
}
}
================================================
FILE: src/utils/conversion/bitsToKilobytes.as
================================================
package utils.conversion
{
/**
Converts bits to kilobytes.
@param bits: The number of bits.
@return Returns the number of kilobits.
*/
public function bitsToKilobytes(bits:Number):Number
{
return bits / 8192;
}
}
================================================
FILE: src/utils/conversion/bytesToBits.as
================================================
package utils.conversion
{
/**
Converts bytes to bits.
@param bytes: The number of bytes.
@return Returns the number of bits.
*/
public function bytesToBits(bytes:Number):Number
{
return bytes * 8;
}
}
================================================
FILE: src/utils/conversion/bytesToKilobits.as
================================================
package utils.conversion
{
/**
Converts bytes to kilobits.
@param bytes: The number of bytes.
@return Returns the number of kilobits.
*/
public function bytesToKilobits(bytes:Number):Number
{
return bytes / 128;
}
}
================================================
FILE: src/utils/conversion/bytesToKilobytes.as
================================================
package utils.conversion
{
/**
Converts bytes to kilobytes.
@param bytes: The number of bytes.
@return Returns the number of kilobytes.
*/
public function bytesToKilobytes(bytes:Number):Number
{
return bytes / 1024;
}
}
================================================
FILE: src/utils/conversion/daysToHours.as
================================================
package utils.conversion
{
/**
Converts days to hours.
@param days: The number of days.
@return Returns the number of hours.
*/
public function daysToHours(days:Number):Number
{
return days * 24;
}
}
================================================
FILE: src/utils/conversion/daysToMilliseconds.as
================================================
package utils.conversion
{
/**
Converts days to milliseconds.
@param days: The number of days.
@return Returns the number of milliseconds.
*/
public function daysToMilliseconds(days:Number):Number
{
return secondsToMilliseconds(daysToSeconds(days));
}
}
================================================
FILE: src/utils/conversion/daysToMinutes.as
================================================
package utils.conversion
{
/**
Converts days to minutes.
@param days: The number of days.
@return Returns the number of minutes.
*/
public function daysToMinutes(days:Number):Number
{
return hoursToMinutes(daysToHours(days));
}
}
================================================
FILE: src/utils/conversion/daysToSeconds.as
================================================
package utils.conversion
{
/**
Converts days to seconds.
@param days: The number of days.
@return Returns the number of seconds.
*/
public function daysToSeconds(days:Number):Number
{
return minutesToSeconds(daysToMinutes(days));
}
}
================================================
FILE: src/utils/conversion/degreesToRadians.as
================================================
package utils.conversion
{
/**
Converts degrees to radians.
@param degrees: The number of degrees.
@return Returns the number of radians.
*/
public function degreesToRadians(degrees:Number):Number
{
return degrees * (Math.PI / 180);
}
}
================================================
FILE: src/utils/conversion/hoursToDays.as
================================================
package utils.conversion
{
/**
Converts hours to days.
@param hours: The number of hours.
@return Returns the number of days.
*/
public function hoursToDays(hours:Number):Number
{
return hours / 24;
}
}
================================================
FILE: src/utils/conversion/hoursToMilliseconds.as
================================================
package utils.conversion
{
/**
Converts hours to milliseconds.
@param hours: The number of hours.
@return Returns the number of milliseconds.
*/
public function hoursToMilliseconds(hours:Number):Number
{
return secondsToMilliseconds(hoursToSeconds(hours));
}
}
================================================
FILE: src/utils/conversion/hoursToMinutes.as
================================================
package utils.conversion
{
/**
Converts hours to minutes.
@param hours: The number of hours.
@return Returns the number of minutes.
*/
public function hoursToMinutes(hours:Number):Number
{
return hours * 60;
}
}
================================================
FILE: src/utils/conversion/hoursToSeconds.as
================================================
package utils.conversion
{
/**
Converts hours to seconds.
@param hours: The number of hours.
@return Returns the number of seconds.
*/
public function hoursToSeconds(hours:Number):Number
{
return minutesToSeconds(hoursToMinutes(hours));
}
}
================================================
FILE: src/utils/conversion/kilobitsToBits.as
================================================
package utils.conversion
{
/**
Converts kilobits to bits.
@param kilobits: The number of kilobits.
@return Returns the number of bits.
*/
public function kilobitsToBits(kilobits:Number):Number
{
return kilobits * 1024;
}
}
================================================
FILE: src/utils/conversion/kilobitsToBytes.as
================================================
package utils.conversion
{
/**
Converts kilobits to bytes.
@param kilobits: The number of kilobits.
@return Returns the number of bytes.
*/
public function kilobitsToBytes(kilobits:Number):Number
{
return kilobits * 128;
}
}
================================================
FILE: src/utils/conversion/kilobitsToKilobytes.as
================================================
package utils.conversion
{
/**
Converts kilobits to kilobytes.
@param kilobytes: The number of kilobits.
@return Returns the number of kilobytes.
*/
public function kilobitsToKilobytes(kilobits:Number):Number
{
return kilobits / 8;
}
}
================================================
FILE: src/utils/conversion/kilobytesToBits.as
================================================
package utils.conversion
{
/**
Converts kilobytes to bits.
@param kilobytes: The number of kilobytes.
@return Returns the number of bits.
*/
public function kilobytesToBits(kilobytes:Number):Number
{
return kilobytes * 8192;
}
}
================================================
FILE: src/utils/conversion/kilobytesToBytes.as
================================================
package utils.conversion
{
/**
Converts kilobytes to bytes.
@param kilobytes: The number of kilobytes.
@return Returns the number of bytes.
*/
public function kilobytesToBytes(kilobytes:Number):Number
{
return kilobytes * 1024;
}
}
================================================
FILE: src/utils/conversion/kilobytesToKilobits.as
================================================
package utils.conversion
{
/**
Converts kilobytes to kilobits.
@param kilobytes: The number of kilobytes.
@return Returns the number of kilobits.
*/
public function kilobytesToKilobits(kilobytes:Number):Number
{
return kilobytes * 8;
}
}
================================================
FILE: src/utils/conversion/millisecondsToDays.as
================================================
package utils.conversion
{
/**
Converts milliseconds to days.
@param milliseconds: The number of milliseconds.
@return Returns the number of days.
*/
public function millisecondsToDays(milliseconds:Number):Number
{
return hoursToDays(millisecondsToHours(milliseconds));
}
}
================================================
FILE: src/utils/conversion/millisecondsToHours.as
================================================
package utils.conversion
{
/**
Converts milliseconds to hours.
@param milliseconds: The number of milliseconds.
@return Returns the number of hours.
*/
public function millisecondsToHours(milliseconds:Number):Number
{
return minutesToHours(millisecondsToMinutes(milliseconds));
}
}
================================================
FILE: src/utils/conversion/millisecondsToMinutes.as
================================================
package utils.conversion
{
/**
Converts milliseconds to minutes.
@param milliseconds: The number of milliseconds.
@return Returns the number of minutes.
*/
public function millisecondsToMinutes(milliseconds:Number):Number
{
return secondsToMinutes(millisecondsToSeconds(milliseconds));
}
}
================================================
FILE: src/utils/conversion/millisecondsToSeconds.as
================================================
package utils.conversion
{
/**
Converts milliseconds to seconds.
@param milliseconds: The number of milliseconds.
@return Returns the number of seconds.
*/
public function millisecondsToSeconds(milliseconds:Number):Number
{
return milliseconds / 1000;
}
}
================================================
FILE: src/utils/conversion/minutesToDays.as
================================================
package utils.conversion
{
/**
Converts minutes to days.
@param minutes: The number of minutes.
@return Returns the number of days.
*/
public function minutesToDays(minutes:Number):Number
{
return hoursToDays(minutesToHours(minutes));
}
}
================================================
FILE: src/utils/conversion/minutesToHours.as
================================================
package utils.conversion
{
/**
Converts minutes to hours.
@param minutes: The number of minutes.
@return Returns the number of hours.
*/
public function minutesToHours(minutes:Number):Number
{
return minutes / 60;
}
}
================================================
FILE: src/utils/conversion/minutesToMilliseconds.as
================================================
package utils.conversion
{
/**
Converts minutes to milliseconds.
@param minutes: The number of minutes.
@return Returns the number of milliseconds.
*/
public function minutesToMilliseconds(minutes:Number):Number
{
return secondsToMilliseconds(minutesToSeconds(minutes));
}
}
================================================
FILE: src/utils/conversion/minutesToSeconds.as
================================================
package utils.conversion
{
/**
Converts minutes to seconds.
@param minutes: The number of minutes.
@return Returns the number of seconds.
*/
public function minutesToSeconds(minutes:Number):Number
{
return minutes * 60;
}
}
================================================
FILE: src/utils/conversion/radiansToDegrees.as
================================================
package utils.conversion
{
/**
Converts radians to degrees.
@param radians: The number of radians.
@return Returns the number of degrees.
*/
public function radiansToDegrees(radians:Number):Number
{
return radians * (180 / Math.PI);
}
}
================================================
FILE: src/utils/conversion/secondsToDays.as
================================================
package utils.conversion
{
/**
Converts seconds to days.
@param seconds: The number of seconds.
@return Returns the number of days.
*/
public function secondsToDays(seconds:Number):Number
{
return hoursToDays(secondsToHours(seconds));
}
}
================================================
FILE: src/utils/conversion/secondsToHours.as
================================================
package utils.conversion
{
/**
Converts seconds to hours.
@param seconds: The number of seconds.
@return Returns the number of hours.
*/
public function secondsToHours(seconds:Number):Number
{
return minutesToHours(secondsToMinutes(seconds));
}
}
================================================
FILE: src/utils/conversion/secondsToMilliseconds.as
================================================
package utils.conversion
{
/**
Converts seconds to milliseconds.
@param seconds: The number of seconds.
@return Returns the number of milliseconds.
*/
public function secondsToMilliseconds(seconds:Number):Number
{
return seconds * 1000;
}
}
================================================
FILE: src/utils/conversion/secondsToMinutes.as
================================================
package utils.conversion
{
/**
Converts seconds to minutes.
@param seconds: The number of seconds.
@return Returns the number of minutes.
*/
public function secondsToMinutes(seconds:Number):Number
{
return seconds / 60;
}
}
================================================
FILE: src/utils/cookie/getCookie.as
================================================
package utils.cookie
{
import flash.external.ExternalInterface;
public function getCookie(cookieName:String):String
{
var r:String = "";
var search:String = cookieName + "=";
var js:String = "function get_cookie(){return document.cookie;}";
var o:Object = ExternalInterface.call(js);
var cookieVariable:String = o.toString();
if (cookieVariable.length > 0)
{
var offset:int = cookieVariable.indexOf(search);
if (offset != -1)
{
offset += search.length;
var end:int = cookieVariable.indexOf(";", offset);
if (end == -1)
end = cookieVariable.length;
r = unescape(cookieVariable.substring(offset, end));
}
}
return r;
}
}
================================================
FILE: src/utils/cookie/setCookie.as
================================================
package utils.cookie
{
import flash.external.ExternalInterface;
public function setCookie(cookieName:String, cookieValue:String):void
{
var js:String = "function sc(){";
js += "var c = escape('" + cookieName + "') + '=' + escape('" + cookieValue + "') + '; path=/';";
js += "document.cookie = c;";
js += "}";
ExternalInterface.call(js);
}
}
================================================
FILE: src/utils/date/Calendar.as
================================================
/**
* User: John Lindquist
* Date: 3/16/11
* Time: 11:27 AM
*/
package utils.date
{
/**
* Calendar is an exception to the "package-level function" rule
*
* This class provides common dates (today, yesterday, tomorrow, last Sunday, next Thursday, the first of the year, the first of June, etc)
* all based on "now"
*
* To determine whether or not a date belongs in "Calendar", simply ask yourself, "Is this date based on 'now'?"
*
* These properties will leverage many of the package-level functions such as "getNextDay", etc, but will simply be based on "now"
*/
public class Calendar
{
public var now:Date = new Date();
public var today:Date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
}
}
================================================
FILE: src/utils/date/TimeRelationships.as
================================================
package utils.date
{
public class TimeRelationships
{
//
// Milliseconds
//
public static const YEAR_IN_MILLISECONDS:Number = 31536000000.0;
public static const THIRTY_ONE_DAY_MONTH_IN_MILLISECONDS:Number = 2678400000.0;
public static const THIRTY_DAY_MONTH_IN_MILLISECONDS:Number = 2592000000.0;
public static const TWENTY_EIGHT_DAY_MONTH_IN_MILLISECONDS:Number = 2419200000.0;
public static const WEEK_IN_MILLISECONDS:Number = 604800000.0;
public static const DAY_IN_MILLISECONDS:Number = 86400000.0;
public static const HOUR_IN_MILLISECONDS:Number = 3600000.0;
public static const MINUTE_IN_MILLISECONDS:Number = 60000.0;
//
// Seconds
//
public static const YEAR_IN_SECONDS:Number = 31536000;
public static const THIRTY_ONE_DAY_MONTH_IN_SECONDS:Number = 2678400;
public static const THIRTY_DAY_MONTH_IN_SECONDS:Number = 2592000;
public static const TWENTY_EIGHT_DAY_MONTH_IN_SECONDS:Number = 2419200;
public static const WEEK_IN_SECONDS:Number = 604800;
public static const DAY_IN_SECONDS:Number = 86400;
public static const HOUR_IN_SECONDS:Number = 3600;
public static const MINUTE_IN_SECONDS:Number = 60;
}
}
================================================
FILE: src/utils/date/Timezone.as
================================================
package utils.date
{
/*
* Need to discuss how to refactor timezone logic into better utils
*
* This class currently only works with USA (the offsets default to EAST if the timezone is outside of the USA.
*
* */
public class Timezone
{
public static const EAST:String = "ET";
public static const WEST:String = "WT";
public static const ARIZONA:String = "AZ";
public static const MOUNTAIN:String = "MT";
public static const CENTRAL:String = "CT";
public static const PACIFIC:String = "PT";
public static const ALASKA:String = "AK";
public static const HAWAII:String = "HT";
private static var nonDstOffsetDate:Date = new Date(2010, 1, 1);
private static var dstOffsetDate:Date = new Date(2010, 7, 1);
private static var observesDST:Boolean = (nonDstOffsetDate.timezoneOffset != dstOffsetDate.timezoneOffset);
private static var timezone:String = EAST;
public static function get zuluOffset():String
{
var offset:Number = nonDstOffsetDate.timezoneOffset / 60;
if(offset > 11 || offset <= 5)
{
offset = 4; //defaulting to east coast
return String(offset);
}
return String(new Date().timezoneOffset / 60);
}
public static function get dstOffset():String
{
var offset:Number = dstOffsetDate.timezoneOffset / 60;
if(offset > 10 || offset <= 4)
{
offset = 4; //defaulting to east coast
}
return String(offset);
}
public static function get nonDstOffset():String
{
var offset:Number = nonDstOffsetDate.timezoneOffset / 60;
if(offset > 11 || offset <= 5)
{
offset = 5; //defaulting to east coast
}
return String(offset);
}
public static function get name():String
{
//Default to Eastern
switch (nonDstOffset)
{
case "10":
timezone = HAWAII; //Hawaii
break;
case "9":
timezone = ALASKA; //Alaska
break;
case "8":
timezone = PACIFIC;//Pacific
break;
case "7":
timezone = MOUNTAIN;//Mountain
if(!observesDST) timezone = ARIZONA;
break;
case "6":
timezone = CENTRAL;//Central
break;
default:
timezone = EAST;
}
return timezone;
}
}
}
================================================
FILE: src/utils/date/addWeeks.as
================================================
package utils.date
{
public function addWeeks(date:Date, weeks:uint):Date
{
date.date += weeks * 7;
return date;
}
}
================================================
FILE: src/utils/date/ceil.as
================================================
package utils.date
{
/**
* Returns the rounded up date where the time is 12:00am.
* If a date is not provided, the current date is used.
* @param date the date to round up
* @return
*/
public function ceil(date:Date = null):Date
{
if (!date)
date = new Date();
date.date += 1.0;
date.hours = 0.0;
date.minutes = 0.0;
date.seconds = 0.0;
date.milliseconds = 0.0;
return date;
}
}
================================================
FILE: src/utils/date/clone.as
================================================
package utils.date
{
public function clone(date:Date):Date
{
return new Date(date.fullYear, date.month, date.date, date.hours, date.minutes, date.seconds, date.milliseconds);
}
}
================================================
FILE: src/utils/date/compareDates.as
================================================
package utils.date
{
/**
* Compares two dates and returns an integer depending on their relationship.
*
* Returns -1 if d1 is later than d2.
* Returns 1 if d2 is later than d1.
* Returns 0 if both dates are equal.
*
* @param d1 The date that will be compared to the second date.
* @param d2 The date that will be compared to the first date.
*
* @return An int indicating how the two dates compare.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*/
public function compareDates(d1:Date, d2:Date):int
{
var d1ms:Number = d1.getTime();
var d2ms:Number = d2.getTime();
if (d1ms > d2ms)
{
return -1;
}
else if (d1ms < d2ms)
{
return 1;
}
else
{
return 0;
}
}
}
================================================
FILE: src/utils/date/dayAbbrNames.as
================================================
package utils.date {
public const dayAbbrNames:Array = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ];
}
================================================
FILE: src/utils/date/dayNames.as
================================================
package utils.date
{
public const dayNames:Array = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ];
}
================================================
FILE: src/utils/date/equals.as
================================================
package utils.date
{
/**
Determines if two Dates are the same time.
@param first: First Date to compare to <code>second</code>.
@param second: Second Date to compare to <code>first</code>.
@return Returns <code>true</code> if Dates are the same; otherwise <code>false</code>.
*/
public function equals(first:Date, second:Date):Boolean
{
return first.valueOf() == second.valueOf();
}
}
================================================
FILE: src/utils/date/floor.as
================================================
package utils.date
{
/**
* Returns the rounded down date where the time is 12:00am.
* If a date is not provided, the current date is used.
* @param date the date to round down
* @return
*/
public function floor(date:Date = null):Date
{
if (!date)
date = new Date();
date.hours = 0.0;
date.minutes = 0.0;
date.seconds = 0.0;
date.milliseconds = 0.0;
return date;
}
}
================================================
FILE: src/utils/date/formatDate.as
================================================
package utils.date {
import utils.conversion.minutesToSeconds;
import utils.number.addLeadingZeroes;
import utils.number.format;
import utils.number.getOrdinalSuffix;
/**
* Formats a Date object for display. Acts almost identically to the PHP date() function.
* You can prevent a recognized character in the format string from being expanded by escaping it with a preceding ^.
* <table border="1">
* <tr>
* <th style="width:150px;">Format character</th>
* <th>Description</th>
* <th style="width:200px;">Example returned values</th>
* </tr>
* <tr>
* <td>d</td>
* <td>Day of the month, 2 digits with leading zeros.</td>
* <td>01 to 31</td>
* </tr>
* <tr>
* <td>D</td>
* <td>A textual representation of a day, three letters.</td>
* <td>Mon through Sun</td>
* </tr>
* <tr>
* <td>j</td>
* <td>Day of the month without leading zeros.</td>
* <td>1 to 31</td>
* </tr>
* <tr>
* <td>l</td>
* <td>A full textual representation of the day of the week.</td>
* <td>Sunday through Saturday</td>
* </tr>
* <tr>
* <td>N</td>
* <td>ISO-8601 numeric representation of the day of the week.</td>
* <td>1 (for Monday) through 7 (for Sunday)</td>
* </tr>
* <tr>
* <td>S</td>
* <td>English ordinal suffix for the day of the month, 2 characters.</td>
* <td>st, nd, rd or th</td>
* </tr>
* <tr>
* <td>w</td>
* <td>Numeric representation of the day of the week.</td>
* <td>0 (for Sunday) through 6 (for Saturday)</td>
* </tr>
* <tr>
* <td>z</td>
* <td>The day of the year (starting from 0).</td>
* <td>0 through 365</td>
* </tr>
* <tr>
* <td>W</td>
* <td>ISO-8601 week number of year, weeks starting on Monday.</td>
* <td>Example: 42 (the 42nd week in the year)</td>
* </tr>
* <tr>
* <td>F</td>
* <td>A full textual representation of a month, such as January or March.</td>
* <td>January through December</td>
* </tr>
* <tr>
* <td>m</td>
* <td>Numeric representation of a month, with leading zeros.</td>
* <td>01 through 12</td>
* </tr>
* <tr>
* <td>M</td>
* <td>A short textual representation of a month, three letters.</td>
* <td>Jan through Dec</td>
* </tr>
* <tr>
* <td>n</td>
* <td>Numeric representation of a month, without leading zeros.</td>
* <td>1 through 12</td>
* </tr>
* <tr>
* <td>t</td>
* <td>Number of days in the given month.</td>
* <td>28 through 31</td>
* </tr>
* <tr>
* <td>L</td>
* <td>Determines if it is a leap year.</td>
* <td>1 if it is a leap year, 0 otherwise</td>
* </tr>
* <tr>
* <td>o or Y</td>
* <td>A full numeric representation of a year, 4 digits.</td>
* <td>Examples: 1999 or 2003</td>
* </tr>
* <tr>
* <td>y</td>
* <td>A two digit representation of a year.</td>
* <td>Examples: 99 or 03</td>
* </tr>
* <tr>
* <td>a</td>
* <td>Lowercase Ante meridiem and Post meridiem.</td>
* <td>am or pm</td>
* </tr>
* <tr>
* <td>A</td>
* <td>Uppercase Ante meridiem and Post meridiem.</td>
* <td>AM or PM</td>
* </tr>
* <tr>
* <td>B</td>
* <td>Swatch Internet time.</td>
* <td>000 through 999</td>
* </tr>
* <tr>
* <td>g</td>
* <td>12-hour format of an hour without leading zeros.</td>
* <td>1 through 12</td>
* </tr>
* <tr>
* <td>G</td>
* <td>24-hour format of an hour without leading zeros.</td>
* <td>0 through 23</td>
* </tr>
* <tr>
* <td>h</td>
* <td>12-hour format of an hour with leading zeros.</td>
* <td>01 through 12</td>
* </tr>
* <tr>
* <td>H</td>
* <td>24-hour format of an hour with leading zeros.</td>
* <td>00 through 23</td>
* </tr>
* <tr>
* <td>i</td>
* <td>Minutes with leading zeros.</td>
* <td>00 to 59</td>
* </tr>
* <tr>
* <td>s</td>
* <td>Seconds, with leading zeros.</td>
* <td>00 through 59</td>
* </tr>
* <tr>
* <td>I</td>
* <td>Determines if the date is in daylight saving time.</td>
* <td>1 if Daylight Saving Time, 0 otherwise</td>
* </tr>
* <tr>
* <td>O</td>
* <td>Difference to coordinated universal time (UTC) in hours.</td>
* <td>Example: +0200</td>
* </tr>
* <tr>
* <td>P</td>
* <td>Difference to Greenwich time (GMT/UTC) in hours with colon between hours and minutes.</td>
* <td>Example: +02:00</td>
* </tr>
* <tr>
* <td>e or T</td>
* <td>Timezone abbreviation.</td>
* <td>Examples: EST, MDT</td>
* </tr>
* <tr>
* <td>Z</td>
* <td>Timezone offset in seconds.</td>
* <td>-43200 through 50400</td>
* </tr>
* <tr>
* <td>c</td>
* <td>ISO 8601 date.</td>
* <td>2004-02-12T15:19:21+00:00</td>
* </tr>
* <tr>
* <td>r</td>
* <td>RFC 2822 formatted date.</td>
* <td>Example: Thu, 21 Dec 2000 16:01:07 +0200</td>
* </tr>
* <tr>
* <td>U</td>
* <td>Seconds since the Unix Epoch.</td>
* <td>Example: 1171479314</td>
* </tr>
* </table>
* Example code:
* <pre>
* trace(DateUtils.formatDate(new Date(), "l ^t^h^e dS ^of F Y h:i:s A"));
* </pre>
* @param dateToFormat Date object you wish to format
* @param formatString Format of the outputted date String. See the format characters options above.
* @author Aaron Clinger
* @author Shane McCartney
* @author David Nelson
*/
public function formatDate(dateToFormat:Date, formatString:String):String {
var out:String = "";
var c:String;
var i:int = -1;
var l:uint = formatString.length;
var t:Number;
while(++i < l) {
c = formatString.substr(i, 1);
if(c == "^") {
out += formatString.substr(++i, 1);
}
else {
switch(c) {
case "d" :
// Day of the month, 2 digits with leading zeros
out += addLeadingZeroes(dateToFormat.getDate());
break;
case "D" :
// A textual representation of a day, three letters
out += getDayAbbrName(dateToFormat.getDay());
break;
case "j" :
// Day of the month without leading zeros
out += String(dateToFormat.getDate());
break;
case "l" :
// A full textual representation of the day of the week
out += getDayAsString(dateToFormat.getDay());
break;
case "N" :
// ISO-8601 numeric representation of the day of the week
t = dateToFormat.getDay();
if(t == 0) t = 7;
out += String(t);
break;
case "S" :
// English ordinal suffix for the day of the month, 2 characters
out += getOrdinalSuffix(dateToFormat.getDate());
break;
case "w" :
// Numeric representation of the day of the week
out += String(dateToFormat.getDay());
break;
case "z" :
// The day of the year (starting from 0)
out += String(addLeadingZeroes(getDayOfTheYear(dateToFormat)));
break;
case "W" :
// ISO-8601 week number of year, weeks starting on Monday
out += String(addLeadingZeroes(getWeekOfTheYear(dateToFormat)));
break;
case "F" :
// A full textual representation of a month, such as January or March
out += getMonthName(dateToFormat.getMonth());
break;
case "m" :
// Numeric representation of a month, with leading zeros
out += addLeadingZeroes(dateToFormat.getMonth() + 1);
break;
case "M" :
// A short textual representation of a month, three letters
out += getMonthAbbrName(dateToFormat.getMonth());
break;
case "n" :
// Numeric representation of a month, without leading zeros
out += String((dateToFormat.getMonth() + 1));
break;
case "t" :
// Number of days in the given month
out += String(getDaysInMonth(dateToFormat.getMonth(), dateToFormat.getFullYear()));
break;
case "L" :
// Whether it is a leap year
out += (isLeapYear(dateToFormat.getFullYear())) ? "1" : "0";
break;
case "o" :
case "Y" :
// A full numeric representation of a year, 4 digits
out += String(dateToFormat.getFullYear());
break;
case "y" :
// A two digit representation of a year
out += String(dateToFormat.getFullYear()).substr(-2);
break;
case "a" :
// Lowercase Ante meridiem and Post meridiem
out += getMeridiem(dateToFormat.getHours()).toLowerCase();
break;
case "A" :
// Uppercase Ante meridiem and Post meridiem
out += getMeridiem(dateToFormat.getHours());
break;
case "B" :
// Swatch Internet time
out += format(getInternetTime(dateToFormat), 3, null, "0");
break;
case "g" :
// 12-hour format of an hour without leading zeros
t = dateToFormat.getHours();
if(t == 0) {
t = 12;
} else if(t > 12) {
t -= 12;
}
out += String(t);
break;
case "G" :
// 24-hour format of an hour without leading zeros
out += String(dateToFormat.getHours());
break;
case "h" :
// 12-hour format of an hour with leading zeros
t = dateToFormat.getHours() + 1;
if(t == 0) {
t = 12;
} else if(t > 12) {
t -= 12;
}
out += addLeadingZeroes(t);
break;
case "H" :
// 24-hour format of an hour with leading zeros
out += addLeadingZeroes(dateToFormat.getHours());
break;
case "i" :
// Minutes with leading zeros
out += addLeadingZeroes(dateToFormat.getMinutes());
break;
case "s" :
// Seconds, with leading zeros
out += addLeadingZeroes(dateToFormat.getSeconds());
break;
case "I" :
// Whether or not the date is in daylights savings time
out += (isDaylightSavings(dateToFormat)) ? "1" : "0";
break;
case "O" :
// Difference to Greenwich time (GMT/UTC) in hours
out += getFormattedDifferenceFromUTC(dateToFormat);
break;
case "P" :
out += getFormattedDifferenceFromUTC(dateToFormat, ":");
break;
case "e" :
case "T" :
// Timezone identifier
out += getTimezone(dateToFormat);
break;
case "Z" :
// Timezone offset (GMT/UTC) in seconds.
out += String(int(minutesToSeconds(dateToFormat.getTimezoneOffset())));
break;
case "c" :
// ISO 8601 date
out += dateToFormat.getFullYear() + "-" + addLeadingZeroes(dateToFormat.getMonth() + 1) + "-" + addLeadingZeroes(dateToFormat.getDate()) + "T" + addLeadingZeroes(dateToFormat.getHours()) + ":" + addLeadingZeroes(dateToFormat.getMinutes()) + ":" + addLeadingZeroes(dateToFormat.getSeconds()) + getFormattedDifferenceFromUTC(dateToFormat, ":");
break;
case "r" :
// RFC 2822 formatted date
out += getDayAbbrName(dateToFormat.getDay()) + ", " + dateToFormat.getDate() + " " + getMonthAbbrName(dateToFormat.getMonth()) + " " + dateToFormat.getFullYear() + " " + addLeadingZeroes(dateToFormat.getHours()) + ":" + addLeadingZeroes(dateToFormat.getMinutes()) + ":" + addLeadingZeroes(dateToFormat.getSeconds()) + " " + getFormattedDifferenceFromUTC(dateToFormat);
break;
case "U" :
// Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
t = int(dateToFormat.getTime() / 1000);
out += String(t);
break;
default :
out += formatString.substr(i, 1);
}
}
}
return out;
}
}
================================================
FILE: src/utils/date/formatWeekOf.as
================================================
package utils.date
{
public function formatWeekOf(date:Date):String
{
date = getLastSunday(date);
var string:String = "";
string = "Week of " + String(date.getUTCMonth() + 1) + "/" + String(date.getUTCDate());
return string;
}
}
================================================
FILE: src/utils/date/getAMPM.as
================================================
package utils.date
{
/**
* Returns a string indicating whether the date represents a time in the
* ante meridiem (AM) or post meridiem (PM).
*
* If the hour is less than 12 then "AM" will be returned.
*
* If the hour is greater than 12 then "PM" will be returned.
*
* @param d1 The Date from which to generate the 12 hour clock indicator.
*
* @return A String ("AM" or "PM") indicating which half of the day the
* hour represents.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*/
public function getAMPM(d:Date):String
{
return (d.hours > 11) ? "PM" : "AM";
}
}
================================================
FILE: src/utils/date/getCountdownUntil.as
================================================
package utils.date
{
import utils.conversion.daysToHours;
import utils.conversion.hoursToMinutes;
import utils.conversion.millisecondsToDays;
import utils.conversion.minutesToSeconds;
import utils.conversion.secondsToMilliseconds;
/**
Determines the time remaining until a certain date.
@param startDate: The starting date.
@param endDate: The ending date.
@return Returns an Object with the properties <code>days</code>, <code>hours</code>, <code>minutes</code>, <code>seconds</code> and <code>milliseconds</code> defined as numbers.
@example
<code>
var countdown:Object = DateUtil.getCountdownUntil(new Date(2006, 11, 31, 21, 36), new Date(2007, 0, 1));
trace("There are " + countdown.hours + " hours and " + countdown.minutes + " minutes until the new year!");
</code>
*/
public function getCountdownUntil(startDate:Date, endDate:Date):Object
{
var daysUntil:Number = millisecondsToDays(getTimeBetween(startDate, endDate));
var hoursUntil:Number = daysToHours(daysUntil % 1);
var minsUntil:Number = hoursToMinutes(hoursUntil % 1);
var secsUntil:Number = minutesToSeconds(minsUntil % 1);
var milliUntil:Number = secondsToMilliseconds(secsUntil % 1);
return {
days: int(daysUntil),
hours: int(hoursUntil),
minutes: int(minsUntil),
seconds: int(secsUntil),
milliseconds: int(milliUntil)};
}
}
================================================
FILE: src/utils/date/getDayAbbrName.as
================================================
package utils.date {
/**
* Returns the English abbreviation name of the provided day.
* @param day the index of the day, where zero returns 'Sun' and six returns 'Sat'
* @return
*/
public function getDayAbbrName(day:int):String {
return dayAbbrNames[day];
}
}
================================================
FILE: src/utils/date/getDayAsString.as
================================================
package utils.date
{
public function getDayAsString(day:Number):String
{
var dayNamesFull:Array = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
return dayNamesFull[day];
}
}
================================================
FILE: src/utils/date/getDayName.as
================================================
package utils.date
{
/**
* Returns the English name of the provided day.
* @param day the index of the day, where zero returns 'Sunday' and six returns 'Saturday'
* @return
*/
public function getDayName(day:int):String
{
return dayNames[day];
}
}
================================================
FILE: src/utils/date/getDayOfTheYear.as
================================================
package utils.date
{
/**
Gets the current day out of the total days in the year (starting from 0).
@param d: Date object to find the current day of the year from.
@return Returns the current day of the year (0-364 or 0-365 on a leap year).
*/
public function getDayOfTheYear(d:Date):uint
{
var firstDay:Date = new Date(d.getFullYear(), 0, 1);
return (d.getTime() - firstDay.getTime()) / 86400000;
}
}
================================================
FILE: src/utils/date/getDaysInMonth.as
================================================
package utils.date
{
/**
Finds the number of days in the given month.
@param year: The full year.
@param month: The month number (0 for January, 1 for February, and so on).
@return The number of days in the month; 28 through 31.
@example
<code>
var myDate:Date = new Date(2000, 0, 1);
trace(DateUtil.getDaysInMonth(myDate.getFullYear(), myDate.getMonth())); // Traces 31
</code>
*/
public function getDaysInMonth(year:Number, month:Number):uint
{
return (new Date(year, ++month, 0)).getDate();
}
}
================================================
FILE: src/utils/date/getEarliestDate.as
================================================
package utils.date
{
/**
* Compares dates and returns the latest one.
*
* @param dates that will be compared.
* @return The latest date.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @author Mims H. Wright
*/
public function getEarliestDate(... dates ):Date
{
var earliestDate:Date;
if (dates.length() == 0) {
throw new ArgumentError("Requires at least one argument");
}
for each (var date:Date in dates) {
if (!earliestDate) {
earliestDate = date;
continue;
}
if (date.getTime() > earliestDate.getTime()) {
earliestDate = date;
}
}
return earliestDate;
}
}
================================================
FILE: src/utils/date/getFormattedDifferenceFromUTC.as
================================================
package utils.date {
import utils.conversion.minutesToHours;
import utils.number.addLeadingZeroes;
/**
* Formats the difference to coordinated undefined time (UTC).
* @param date Date object to find the time zone offset of
* @param separator Character(s) that separates the hours from minutes
* @return Formatted time difference from UTC
*/
public function getFormattedDifferenceFromUTC(date:Date, separator:String = ""):String {
var pre:String = (-date.getTimezoneOffset() < 0) ? "-" : "+";
return pre + addLeadingZeroes(Math.floor(minutesToHours(date.getTimezoneOffset()))) + separator + addLeadingZeroes(date.getTimezoneOffset() % 60);
}
}
================================================
FILE: src/utils/date/getInternetTime.as
================================================
package utils.date
{
import utils.conversion.minutesToHours;
import utils.conversion.secondsToHours;
/**
Converts current time into Swatch internet time or beats.
@param d: Date object to convert.
@return Returns time in beats (0 to 999).
*/
public function getInternetTime(d:Date):Number
{
var beats:uint = ((d.getUTCHours() + 1 + minutesToHours(d.getUTCMinutes()) + secondsToHours(d.getUTCSeconds())) / 0.024);
return (beats > 1000) ? beats - 1000 : beats;
}
}
================================================
FILE: src/utils/date/getLastMonday.as
================================================
package utils.date
{
public function getLastMonday(date:Date):Date
{
date.date -= (date.day - 1);
return date;
}
}
================================================
FILE: src/utils/date/getLastSunday.as
================================================
package utils.date
{
public function getLastSunday(date:Date):Date
{
var temp:Date = clone(date);
temp.date -= temp.day;
return temp;
}
}
================================================
FILE: src/utils/date/getLatestDate.as
================================================
package utils.date
{
/**
* Compares dates and returns the latest one.
*
* @param dates that will be compared.
* @return The latest date.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @author Mims H. Wright
*/
public function getLatestDate(... dates ):Date
{
var latestDate:Date;
if (dates.length() == 0) {
throw new ArgumentError("Requires at least one argument");
}
for each (var date:Date in dates) {
if (!latestDate) {
latestDate = date;
continue;
}
if (date.getTime() > latestDate.getTime()) {
latestDate = date;
}
}
return latestDate;
}
}
================================================
FILE: src/utils/date/getMeridiem.as
================================================
package utils.date
{
/**
Determines if time is Ante meridiem or Post meridiem.
@param hours: The hour to find the meridiem of (an integer from 0 to 23).
@return Returns either <code>"AM"</code> or <code>"PM"</code>
@example
<code>
trace(DateUtil.getMeridiem(17)); // Traces PM
</code>
*/
public function getMeridiem(hours:Number):String
{
return (hours < 12) ? 'AM' : 'PM';
}
}
================================================
FILE: src/utils/date/getMonthAbbrName.as
================================================
package utils.date {
/**
* Returns the English abbreviation name of the provided month.
* @param month the index of the month, starting at zero
* @return
*/
public function getMonthAbbrName(month:int):String {
return monthAbbrNames[month];
}
}
================================================
FILE: src/utils/date/getMonthName.as
================================================
package utils.date
{
/**
* Returns the English name of the provided month.
* @param month the index of the month, starting at zero
* @return
*/
public function getMonthName(month:int):String
{
return monthNames[month];
}
}
================================================
FILE: src/utils/date/getNextDay.as
================================================
package utils.date
{
/** Returns the next calender date following the provided Date.
* If no Date is provided, the current date is used.
* @param startDate The date you wish to get the next day of
* @return
*/
public function getNextDay(startDate:Date=null):Date
{
const millisecondsPerDay:int = 1000 * 60 * 60 * 24;
if(!startDate)
startDate = new Date();
//scrub the time of day
var tmpDate:Date = new Date(startDate.getFullYear(),
startDate.getMonth(),
startDate.getDate());
tmpDate.setTime(tmpDate.getTime() + millisecondsPerDay);
return tmpDate;
}
}
================================================
FILE: src/utils/date/getPreviousDay.as
================================================
package utils.date
{
/** Returns the previous calender date to the provided Date.
* If no Date is provided, the current date is used.
* @param startDate The date you wish to get the previous day of
* @return
*/
public function getPreviousDay(startDate:Date=null):Date
{
const millisecondsPerDay:int = 1000 * 60 * 60 * 24;
if(!startDate)
startDate = new Date();
//scrub the time of day
var tmpDate:Date = new Date(startDate.getFullYear(),
startDate.getMonth(),
startDate.getDate());
return new Date(tmpDate.getTime() - millisecondsPerDay);
}
}
================================================
FILE: src/utils/date/getShortHour.as
================================================
package utils.date
{
/**
* Returns a short hour (0 - 12) represented by the specified date.
*
* If the hour is less than 12 (0 - 11 AM) then the hour will be returned.
*
* If the hour is greater than 12 (12 - 23 PM) then the hour minus 12
* will be returned.
*
* @param d1 The Date from which to generate the short hour
*
* @return An int between 0 and 13 ( 1 - 12 ) representing the short hour.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*/
public function getShortHour(d:Date):int
{
var h:int = d.hours;
if (h == 0 || h == 12)
{
return 12;
}
else if (h > 12)
{
return h - 12;
}
else
{
return h;
}
}
}
================================================
FILE: src/utils/date/getShortYear.as
================================================
package utils.date
{
/**
* Returns a two digit representation of the year represented by the
* specified date.
*
* @param d The Date instance whose year will be used to generate a two
* digit string representation of the year.
*
* @return A string that contains a 2 digit representation of the year.
* Single digits will be padded with 0.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*/
public function getShortYear(d:Date):String
{
var dStr:String = String(d.getFullYear());
if (dStr.length < 3)
{
return dStr;
}
return (dStr.substr(dStr.length - 2));
}
}
================================================
FILE: src/utils/date/getStartOfWeek.as
================================================
package utils.date
{
public function getStartOfWeek(date:Date):Date
{
var temp:Date = clone(date);
temp.date -= temp.day;
temp = makeMorning(temp);
return temp;
}
}
================================================
FILE: src/utils/date/getTimeBetween.as
================================================
package utils.date
{
/**
Determines the difference between two dates.
@param startDate: The starting date.
@param endDate: The ending date.
@return Returns the difference in milliseconds between the two dates.
@example
<code>
trace(ConversionUtil.millisecondsToDays(DateUtil.getTimeBetween(new Date(2007, 0, 1), new Date(2007, 0, 11)))); // Traces 10
</code>
*/
public function getTimeBetween(startDate:Date, endDate:Date):Number
{
return endDate.getTime() - startDate.getTime();
}
}
================================================
FILE: src/utils/date/getTimeElapsedString.as
================================================
package utils.date
{
/**
* Takes a Date object and returns a string in the format
* "X UNITS ago" where X is a number and UNITS is a unit of
* time. Also has some other strings like "yesterday".
*
* @author Mims Wright (with thanks to John Resig)
*
* @param date The date to convert to a past string.
* @param now Optional time to compare against. Default will be the present.
*/
public function getTimeElapsedString(date:Date, now:Date = null):String {
const SEC_PER_MINUTE:int = 60;
const SEC_PER_HOUR:int = SEC_PER_MINUTE * 60;
const SEC_PER_DAY:int = SEC_PER_HOUR * 24;
const SEC_PER_WEEK:int = SEC_PER_DAY * 7;
const SEC_PER_MONTH:int = SEC_PER_DAY * 30;
const SEC_PER_YEAR:int = SEC_PER_MONTH * 12;
// if now isn't defined, make it a new Date object (the present)
if (!now) { now = new Date(); }
// don't use secondsElapsed here because the values are
// huge so they use uints and are never negative
if (now.time < date.time) { return "in the future"; }
// get the difference in seconds between the two values.
var secondsElapsed:uint = Math.floor((now.time - date.time) / 1000);
// seconds
if (secondsElapsed < SEC_PER_MINUTE) { return "just now"; }
// minutes
if (secondsElapsed < SEC_PER_HOUR) {
var minutes:int = int(secondsElapsed / SEC_PER_MINUTE);
return formatAgoString(minutes, "minute");
}
// hours
if (secondsElapsed < SEC_PER_DAY) {
var hours:int = int(secondsElapsed / SEC_PER_HOUR);
return formatAgoString(hours, "hour");
}
// days
if (secondsElapsed < SEC_PER_WEEK) {
var days:int = int(secondsElapsed / SEC_PER_DAY);
if (days == 1) { return "yesterday"; }
return formatAgoString(days, "day");
}
// weeks
if (secondsElapsed < SEC_PER_MONTH) {
var weeks:int = int(secondsElapsed / SEC_PER_WEEK);
return formatAgoString(weeks, "week");
}
// months
if (secondsElapsed < SEC_PER_YEAR) {
var months:int = int(secondsElapsed / SEC_PER_MONTH);
return formatAgoString(months, "month");
}
// years
return "more than a year ago";
// Returns a string in the format "count unit(s) ago"
function formatAgoString(count:int, unit:String):String {
return count + " " + unit + (count > 1 ? "s" : "") + " ago";
}
}
}
================================================
FILE: src/utils/date/getTimezone.as
================================================
package utils.date
{
/**
Determines the time zone of the user from a Date object.
@param d: Date object to find the time zone of.
@return Returns the time zone abbreviation.
@example
<code>
trace(DateUtil.getTimezone(new Date()));
</code>
*/
public function getTimezone(d:Date):String
{
var timeZones:Array =
new Array('IDLW', 'NT', 'HST', 'AKST', 'PST', 'MST', 'CST', 'EST', 'AST', 'ADT', 'AT', 'WAT', 'GMT', 'CET', 'EET', 'MSK', 'ZP4', 'ZP5', 'ZP6', 'WAST', 'WST', 'JST', 'AEST', 'AEDT',
'NZST');
var hour:uint = Math.round(12 + -(d.getTimezoneOffset() / 60));
if (isDaylightSavings(d))
hour--;
return timeZones[hour];
}
}
================================================
FILE: src/utils/date/getUTCDate.as
================================================
package utils.date
{
/**
* Sort of converts a date into UTC.
*/
public function getUTCDate(d:Date):Date
{
var nd:Date = new Date();
var offset:Number = d.getTimezoneOffset() * 60 * 1000;
nd.setTime(d.getTime() + offset);
return nd;
}
}
================================================
FILE: src/utils/date/getWeekOfTheYear.as
================================================
package utils.date
{
import utils.conversion.millisecondsToDays;
/**
Determines the week number of year, weeks start on Mondays.
@param d: Date object to find the current week number of.
@return Returns the the week of the year the date falls in.
*/
public function getWeekOfTheYear(d:Date):uint
{
var firstDay:Date = new Date(d.getFullYear(), 0, 1);
var dayOffset:uint = 9 - firstDay.getDay();
var firstMonday:Date = new Date(d.getFullYear(), 0, (dayOffset > 7) ? dayOffset - 7 : dayOffset);
var currentDay:Date = new Date(d.getFullYear(), d.getMonth(), d.getDate());
var weekNumber:uint = (millisecondsToDays(currentDay.getTime() - firstMonday.getTime()) / 7) + 1;
return (weekNumber == 0) ? getWeekOfTheYear(new Date(d.getFullYear() - 1, 11, 31)) : weekNumber;
}
}
================================================
FILE: src/utils/date/isDaylightSavings.as
================================================
package utils.date
{
/**
Determines if or not the date is in daylight saving time.
@param d: Date to find if it is during daylight savings time.
@return Returns <code>true</code> if daylight savings time; otherwise <code>false</code>.
*/
public function isDaylightSavings(d:Date):Boolean
{
var months:uint = 12;
var offset:uint = d.getTimezoneOffset();
var offsetCheck:Number;
while (months--)
{
offsetCheck = (new Date(d.getFullYear(), months, 1)).getTimezoneOffset();
if (offsetCheck != offset)
return (offsetCheck > offset);
}
return false;
}
}
================================================
FILE: src/utils/date/isInCurrentWeek.as
================================================
package utils.date
{
public function isInCurrentWeek(date:Date):Boolean
{
var today:Date = new Date();
var startOfWeek:Date = getStartOfWeek(today);
var millisecondsDifference:Number = getTimeBetween(startOfWeek, date);
var b:Boolean;
b = millisecondsDifference < TimeRelationships.WEEK_IN_MILLISECONDS;
b &&= millisecondsDifference >= 0;
return b;
}
}
================================================
FILE: src/utils/date/isLeapYear.as
================================================
package utils.date
{
/**
Determines if year is a leap year or a common year.
@param year: The full year.
@return Returns <code>true</code> if year is a leap year; otherwise <code>false</code>.
@example
<code>
var myDate:Date = new Date(2000, 0, 1);
trace(DateUtil.isLeapYear(myDate.getFullYear())); // Traces true
</code>
*/
public function isLeapYear(year:Number):Boolean
{
return getDaysInMonth(year, 1) == 29;
}
}
================================================
FILE: src/utils/date/isPast.as
================================================
package utils.date
{
/**
* Returns true if date is in the past.
* If the date is exactly equal to the current time, it will return false.
*
* @author Mims H. Wright
*/
public function isPast(date:Date):Boolean
{
return (new Date().getTime() - date.getTime()) > 0;
}
}
================================================
FILE: src/utils/date/iso8601ToDate.as
================================================
package utils.date {
import utils.conversion.minutesToHours;
import utils.object.isEmpty;
/**
* Converts W3C ISO 8601 date String into a Date object.
* Example code:
* <pre>
* trace(iso8601ToDate("1994-11-05T08:15:30-05:00").toString());
* </pre>
* @param iso8601 Valid ISO 8601 formatted String
* @return Date object of the specified date and time of the ISO 8601 String in universal time
* @see http://www.w3.org/TR/NOTE-datetime (W3C ISO 8601 specification)
* @author Aaron Clinger
* @author Shane McCartney
* @author David Nelson
*/
public function iso8601ToDate(iso8601:String):Date {
var parts:Array = iso8601.toUpperCase().split("T");
var date:Array = parts[0].split("-");
var time:Array = (parts.length <= 1) ? [] : parts[1].split(":");
var year:uint = isEmpty(date[0]) ? 0 : Number(date[0]);
var month:uint = isEmpty(date[1]) ? 0 : Number(date[1] - 1);
var day:uint = isEmpty(date[2]) ? 1 : Number(date[2]);
var hour:int = isEmpty(time[0]) ? 0 : Number(time[0]);
var minute:uint = isEmpty(time[1]) ? 0 : Number(time[1]);
var second:uint = 0;
var millisecond:uint = 0;
if(time[2] != undefined) {
var index:int = time[2].length;
var temp:Number;
if(time[2].indexOf("+") > -1) {
index = time[2].indexOf("+");
} else if(time[2].indexOf("-") > -1) {
index = time[2].indexOf("-");
} else if(time[2].indexOf("Z") > -1) {
index = time[2].indexOf("Z");
}
if(isNaN(index)) {
temp = Number(time[2].slice(0, index));
second = Math.floor(temp);
millisecond = 1000 * (temp % 1);
}
if(index != time[2].length) {
var offset:String = time[2].slice(index);
var userOffset:Number = minutesToHours(new Date(year, month, day).getTimezoneOffset());
switch(offset.charAt(0)) {
case "+" :
case "-" :
hour -= userOffset + Number(offset.slice(0));
break;
case "Z" :
hour -= userOffset;
break;
default:
}
}
}
return new Date(year, month, day, hour, minute, second, millisecond);
}
}
================================================
FILE: src/utils/date/makeMorning.as
================================================
package utils.date
{
/**
* Converts a date into just after midnight.
*/
public function makeMorning(d:Date):Date
{
d = new Date(d.time);
d.hours = 0;
d.minutes = 0;
d.seconds = 0;
d.milliseconds = 0;
return d;
}
}
================================================
FILE: src/utils/date/makeNight.as
================================================
package utils.date {
/**
* Converts a date into just before midnight.
*/
public function makeNight(d:Date):Date {
d = new Date(d.time);
d.hours = 23;
d.minutes = 59;
d.seconds = 59;
d.milliseconds = 999;
return d;
}
}
================================================
FILE: src/utils/date/monthAbbrNames.as
================================================
package utils.date {
public const monthAbbrNames:Array = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
}
================================================
FILE: src/utils/date/monthNames.as
================================================
package utils.date
{
public const monthNames:Array = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
}
================================================
FILE: src/utils/date/parseW3CDTF.as
================================================
package utils.date
{
/**
* Parses dates that conform to the W3C Date-time Format into Date objects.
*
* This function is useful for parsing RSS 1.0 and Atom 1.0 dates.
*
* @param str
*
* @returns Date
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*
* @see http://www.w3.org/TR/NOTE-datetime
*/
public function parseW3CDTF(str:String):Date
{
var finalDate:Date;
try
{
var dateStr:String = str.substring(0, str.indexOf("T"));
var timeStr:String = str.substring(str.indexOf("T") + 1, str.length);
var dateArr:Array = dateStr.split("-");
var year:Number = Number(dateArr.shift());
var month:Number = Number(dateArr.shift());
var date:Number = Number(dateArr.shift());
var multiplier:Number;
var offsetHours:Number;
var offsetMinutes:Number;
var offsetStr:String;
if (timeStr.indexOf("Z") != -1)
{
multiplier = 1;
offsetHours = 0;
offsetMinutes = 0;
timeStr = timeStr.replace("Z", "");
}
else if (timeStr.indexOf("+") != -1)
{
multiplier = 1;
offsetStr = timeStr.substring(timeStr.indexOf("+") + 1, timeStr.length);
offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":")));
offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":") + 1, offsetStr.length));
timeStr = timeStr.substring(0, timeStr.indexOf("+"));
}
else // offset is -
{
multiplier = -1;
offsetStr = timeStr.substring(timeStr.indexOf("-") + 1, timeStr.length);
offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":")));
offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":") + 1, offsetStr.length));
timeStr = timeStr.substring(0, timeStr.indexOf("-"));
}
var timeArr:Array = timeStr.split(":");
var hour:Number = Number(timeArr.shift());
var minutes:Number = Number(timeArr.shift());
var secondsArr:Array = (timeArr.length > 0) ? String(timeArr.shift()).split(".") : null;
var seconds:Number = (secondsArr != null && secondsArr.length > 0) ? Number(secondsArr.shift()) : 0;
//var milliseconds:Number = (secondsArr != null && secondsArr.length > 0) ? Number(secondsArr.shift()) : 0;
var milliseconds:Number = (secondsArr != null && secondsArr.length > 0) ? 1000 * parseFloat("0." + secondsArr.shift()) : 0;
var utc:Number = Date.UTC(year, month - 1, date, hour, minutes, seconds, milliseconds);
var offset:Number = (((offsetHours * 3600000) + (offsetMinutes * 60000)) * multiplier);
finalDate = new Date(utc - offset);
if (finalDate.toString() == "Invalid Date")
{
throw new Error("This date does not conform to W3CDTF.");
}
}
catch (e:Error)
{
var eStr:String = "Unable to parse the string [" + str + "] into a date. ";
eStr += "The internal error was: " + e.toString();
throw new Error(eStr);
}
return finalDate;
}
}
================================================
FILE: src/utils/date/timeCode.as
================================================
package utils.date {
/**
* Utility function for generating time code given a number seconds.
* @param sec Seconds
* @return Timecode
* @author Vaclav Vancura (http://vancura.org, http://twitter.com/vancura)
*/
public function timeCode(sec:Number):String {
var h:Number = Math.floor(sec / 3600);
var m:Number = Math.floor((sec % 3600) / 60);
var s:Number = Math.floor((sec % 3600) % 60);
return (h == 0 ? ""
: (h < 10 ? "0" + String(h) + ":" : String(h) + ":"))
+ (m < 10 ? "0" + String(m) : String(m)) + ":"
+ (s < 10 ? "0" + String(s) : String(s));
}
}
================================================
FILE: src/utils/date/toW3CDTF.as
================================================
package utils.date
{
/**
* Returns a date string formatted according to W3CDTF.
*
* @param d
* @param includeMilliseconds Determines whether to include the
* milliseconds value (if any) in the formatted string.
*
* @returns String
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*
* @see http://www.w3.org/TR/NOTE-datetime
*/
public function toW3CDTF(d:Date, includeMilliseconds:Boolean = false):String
{
var date:Number = d.getUTCDate();
var month:Number = d.getUTCMonth();
var hours:Number = d.getUTCHours();
var minutes:Number = d.getUTCMinutes();
var seconds:Number = d.getUTCSeconds();
var milliseconds:Number = d.getUTCMilliseconds();
var sb:String = new String();
sb += String(d.getUTCFullYear());
sb += "-";
//thanks to "dom" who sent in a fix for the line below
if (month + 1 < 10)
{
sb += "0";
}
sb += String(month + 1);
sb += "-";
if (date < 10)
{
sb += "0";
}
sb += String(date);
sb += "T";
if (hours < 10)
{
sb += "0";
}
sb += String(hours);
sb += ":";
if (minutes < 10)
{
sb += "0";
}
sb += String(minutes);
sb += ":";
if (seconds < 10)
{
sb += "0";
}
sb += String(seconds);
if (includeMilliseconds && milliseconds > 0)
{
sb += ".";
sb += String(milliseconds);
}
sb += "-00:00";
return sb;
}
}
================================================
FILE: src/utils/date/toggleAMPM.as
================================================
package utils.date
{
/**
* If a date is AM, changes it to PM and vice versa.
*
* @author Mims H. Wright
*
* @param date The Date to flip.
* @returns A new date object, 12 hours later or earlier depending.
*/
public function toggleAMPM(date:Date):Date
{
var d:Date = new Date(date.time);
if (getAMPM(date) == "PM") {
d.hours -= 12;
} else {
d.hours += 12;
}
return d;
}
}
================================================
FILE: src/utils/dictionary/CircularDictionary.as
================================================
package utils.dictionary
{
import flash.errors.IllegalOperationError;
import flash.utils.Dictionary;
/**
* A dictionary which allows a pairing of two values to point to each other.
* For example, if you have two objects, A and B, A would point to B and
* B would point to A.
*
* @example <listing version="3.0">
* var dict:CircularDictionary = new CircularDictionary();
* dict.addPair(A, B);
* dict.getCounterpartTo(A); // B
* dict.getCounterpartTo(B); // A
* dict.getCounterpartTo(dict.getCounterpartTo(A)); // A
* dict.dictionary[B]; // A. Same as getCounterpartTo(B)
* dict.removePair(B); // removes both A and B.
* </listing>
*
* @author Mims H. Wright
*/
public class CircularDictionary
{
private var _dictionary:Dictionary;
public function get dictionary():Dictionary { return _dictionary; }
/**
* Constructor.
*
* @param useWeakReferences Indicates whether the internal dictionary should use weak references.
*/
public function CircularDict
gitextract_mxl70_5m/
├── .gitignore
├── Contribution Guidelines.md
├── Libraries to integrate.md
├── NOTES.md
├── README.md
├── TODO.md
├── bin/
│ └── as3-utils.swc
├── build/
│ ├── flexunit/
│ │ └── flexUnitTasks-4.1.0-33.jar
│ └── pmd/
│ ├── LICENSE.txt
│ ├── as3-parser-1.1.jar
│ ├── as3-parser-api-1.1.jar
│ ├── as3-plugin-utils-1.1.jar
│ ├── commons-lang-2.4.jar
│ ├── dom4j-1.6.1.jar
│ ├── flex-pmd-ant-task-1.1.jar
│ ├── flex-pmd-command-line-1.1.jar
│ ├── flex-pmd-command-line-api-1.1.jar
│ ├── flex-pmd-core-1.1.jar
│ ├── flex-pmd-cpd-1.1.jar
│ ├── flex-pmd-cpd-ant-task-1.1.jar
│ ├── flex-pmd-cpd-command-line-1.1.jar
│ ├── flex-pmd-files-1.1.jar
│ ├── flex-pmd-metrics-1.1.jar
│ ├── flex-pmd-metrics-ant-task-1.1.jar
│ ├── flex-pmd-metrics-command-line-1.1.jar
│ ├── flex-pmd-ruleset-1.1.jar
│ ├── flex-pmd-ruleset-api-1.1.jar
│ ├── jsap-2.1.jar
│ ├── plexus-utils-1.0.2.jar
│ └── pmd-4.2.5.jar
├── build.properties
├── build.xml
├── libs/
│ ├── flexunit-4.1.0-33-as3_3.5.0.12683.swc
│ ├── flexunit-cilistener-4.1.0-33-3.5.0.12683.swc
│ ├── flexunit-uilistener-4.1.0-33-3.5.0.12683.swc
│ ├── hamcrest-as3-flex-1.1.3.swc
│ └── mockolate-0.9.3.swc
├── res/
│ └── flex-formatter.properties
├── src/
│ ├── .gitignore
│ ├── deprecated/
│ │ ├── .gitignore
│ │ ├── confine.as
│ │ ├── constrain.as
│ │ ├── getURL.as
│ │ ├── randomBoolean.as
│ │ ├── randomRangeFloat.as
│ │ └── randomRangeInt.as
│ └── utils/
│ ├── align/
│ │ ├── alignCenter.as
│ │ ├── alignLeft.as
│ │ ├── alignRight.as
│ │ ├── alignToRectangleBottom.as
│ │ ├── alignToRectangleCenter.as
│ │ ├── alignToRectangleCenterMiddle.as
│ │ ├── alignToRectangleLeft.as
│ │ ├── alignToRectangleMiddle.as
│ │ ├── alignToRectangleRight.as
│ │ ├── alignToRectangleTop.as
│ │ ├── getPositionToTheRightOf.as
│ │ ├── getPositionUnder.as
│ │ ├── gridAlignSpaceNumber.as
│ │ ├── gridAlignSpaceNumberGap.as
│ │ ├── horizontalAlign.as
│ │ ├── horizontalAlignNoSpace.as
│ │ ├── horizontalAlignSpaceArray.as
│ │ ├── horizontalAlignSpaceNumber.as
│ │ ├── interpolate.as
│ │ ├── interpolateMultiX.as
│ │ ├── interpolateMultiY.as
│ │ ├── interpolateX.as
│ │ ├── interpolateY.as
│ │ ├── verticalAlign.as
│ │ ├── verticalAlignNoSpace.as
│ │ ├── verticalAlignSpaceArray.as
│ │ ├── verticalAlignSpaceNumber.as
│ │ ├── xAlignCenter.as
│ │ ├── xAlignLeft.as
│ │ ├── xAlignRight.as
│ │ ├── yAlignCenter.as
│ │ ├── yAlignLeft.as
│ │ └── yAlignRight.as
│ ├── array/
│ │ ├── addItemsAt.as
│ │ ├── arrayContainsValue.as
│ │ ├── arraysAreEqual.as
│ │ ├── average.as
│ │ ├── contains.as
│ │ ├── containsAll.as
│ │ ├── containsAny.as
│ │ ├── copyArray.as
│ │ ├── createUniqueCopy.as
│ │ ├── equals.as
│ │ ├── getHighestValue.as
│ │ ├── getIndexOfDifference.as
│ │ ├── getItemByKey.as
│ │ ├── getItemByType.as
│ │ ├── getItemsByKey.as
│ │ ├── getItemsByType.as
│ │ ├── getLowestValue.as
│ │ ├── getRandomElement.as
│ │ ├── randomize.as
│ │ ├── removeDuplicates.as
│ │ ├── removeItem.as
│ │ ├── removeItems.as
│ │ ├── removeValueFromArray.as
│ │ ├── retainItems.as
│ │ └── sum.as
│ ├── assert/
│ │ ├── assertArrayContains.as
│ │ ├── assertArrayItemsTypeOf.as
│ │ ├── assertDictionaryKeysTypeOf.as
│ │ ├── assertHasText.as
│ │ ├── assertInstanceOf.as
│ │ ├── assertIsTrue.as
│ │ ├── assertNotNull.as
│ │ └── assertState.as
│ ├── boolean/
│ │ ├── randomBoolean.as
│ │ └── randomChance.as
│ ├── capabilities/
│ │ ├── getPlayerInfo.as
│ │ ├── isAirApplication.as
│ │ ├── isIDE.as
│ │ ├── isMac.as
│ │ ├── isPC.as
│ │ ├── isPlugin.as
│ │ ├── isStandAlone.as
│ │ └── isWeb.as
│ ├── color/
│ │ ├── HSLtoHSV.as
│ │ ├── HSLtoRGB.as
│ │ ├── HSVtoHSL.as
│ │ ├── HSVtoRGB.as
│ │ ├── HueToRGB.as
│ │ ├── RGBToHue.as
│ │ ├── RGBtoHSL.as
│ │ ├── RGBtoHSV.as
│ │ ├── averageBlue.as
│ │ ├── averageColorProperty.as
│ │ ├── averageGreen.as
│ │ ├── averageHue.as
│ │ ├── averageLightness.as
│ │ ├── averageRed.as
│ │ ├── averageSaturation.as
│ │ ├── averageValue.as
│ │ ├── changeContrast.as
│ │ ├── getARGB.as
│ │ ├── getColor.as
│ │ ├── getColorFromDisplayObject.as
│ │ ├── getHexStringFromARGB.as
│ │ ├── getHexStringFromRGB.as
│ │ ├── getRGB.as
│ │ ├── getTransform.as
│ │ ├── interpolateColor.as
│ │ ├── invertColor.as
│ │ ├── randomColor.as
│ │ ├── resetColor.as
│ │ ├── setARGB.as
│ │ ├── setColor.as
│ │ ├── setTransform.as
│ │ ├── toColor.as
│ │ ├── toGrayscale.as
│ │ ├── toHTML.as
│ │ ├── toHexString.as
│ │ └── toRGBComponents.as
│ ├── conversion/
│ │ ├── bitsToBytes.as
│ │ ├── bitsToKilobits.as
│ │ ├── bitsToKilobytes.as
│ │ ├── bytesToBits.as
│ │ ├── bytesToKilobits.as
│ │ ├── bytesToKilobytes.as
│ │ ├── daysToHours.as
│ │ ├── daysToMilliseconds.as
│ │ ├── daysToMinutes.as
│ │ ├── daysToSeconds.as
│ │ ├── degreesToRadians.as
│ │ ├── hoursToDays.as
│ │ ├── hoursToMilliseconds.as
│ │ ├── hoursToMinutes.as
│ │ ├── hoursToSeconds.as
│ │ ├── kilobitsToBits.as
│ │ ├── kilobitsToBytes.as
│ │ ├── kilobitsToKilobytes.as
│ │ ├── kilobytesToBits.as
│ │ ├── kilobytesToBytes.as
│ │ ├── kilobytesToKilobits.as
│ │ ├── millisecondsToDays.as
│ │ ├── millisecondsToHours.as
│ │ ├── millisecondsToMinutes.as
│ │ ├── millisecondsToSeconds.as
│ │ ├── minutesToDays.as
│ │ ├── minutesToHours.as
│ │ ├── minutesToMilliseconds.as
│ │ ├── minutesToSeconds.as
│ │ ├── radiansToDegrees.as
│ │ ├── secondsToDays.as
│ │ ├── secondsToHours.as
│ │ ├── secondsToMilliseconds.as
│ │ └── secondsToMinutes.as
│ ├── cookie/
│ │ ├── getCookie.as
│ │ └── setCookie.as
│ ├── date/
│ │ ├── Calendar.as
│ │ ├── TimeRelationships.as
│ │ ├── Timezone.as
│ │ ├── addWeeks.as
│ │ ├── ceil.as
│ │ ├── clone.as
│ │ ├── compareDates.as
│ │ ├── dayAbbrNames.as
│ │ ├── dayNames.as
│ │ ├── equals.as
│ │ ├── floor.as
│ │ ├── formatDate.as
│ │ ├── formatWeekOf.as
│ │ ├── getAMPM.as
│ │ ├── getCountdownUntil.as
│ │ ├── getDayAbbrName.as
│ │ ├── getDayAsString.as
│ │ ├── getDayName.as
│ │ ├── getDayOfTheYear.as
│ │ ├── getDaysInMonth.as
│ │ ├── getEarliestDate.as
│ │ ├── getFormattedDifferenceFromUTC.as
│ │ ├── getInternetTime.as
│ │ ├── getLastMonday.as
│ │ ├── getLastSunday.as
│ │ ├── getLatestDate.as
│ │ ├── getMeridiem.as
│ │ ├── getMonthAbbrName.as
│ │ ├── getMonthName.as
│ │ ├── getNextDay.as
│ │ ├── getPreviousDay.as
│ │ ├── getShortHour.as
│ │ ├── getShortYear.as
│ │ ├── getStartOfWeek.as
│ │ ├── getTimeBetween.as
│ │ ├── getTimeElapsedString.as
│ │ ├── getTimezone.as
│ │ ├── getUTCDate.as
│ │ ├── getWeekOfTheYear.as
│ │ ├── isDaylightSavings.as
│ │ ├── isInCurrentWeek.as
│ │ ├── isLeapYear.as
│ │ ├── isPast.as
│ │ ├── iso8601ToDate.as
│ │ ├── makeMorning.as
│ │ ├── makeNight.as
│ │ ├── monthAbbrNames.as
│ │ ├── monthNames.as
│ │ ├── parseW3CDTF.as
│ │ ├── timeCode.as
│ │ ├── toW3CDTF.as
│ │ └── toggleAMPM.as
│ ├── dictionary/
│ │ ├── CircularDictionary.as
│ │ ├── getKeys.as
│ │ └── getValues.as
│ ├── display/
│ │ ├── Alignment.as
│ │ ├── IDisplayObject.as
│ │ ├── addChild.as
│ │ ├── applyNaturalScrollRect.as
│ │ ├── bringForward.as
│ │ ├── bringToFront.as
│ │ ├── centerWithin.as
│ │ ├── createBitmap.as
│ │ ├── createThumb.as
│ │ ├── cropBitmapData.as
│ │ ├── duplicateDisplayObject.as
│ │ ├── filterChildrenByProps.as
│ │ ├── findAncestor.as
│ │ ├── findAncestorWithType.as
│ │ ├── fitIntoRect.as
│ │ ├── getChildren.as
│ │ ├── getFullBounds.as
│ │ ├── getParents.as
│ │ ├── isVisible.as
│ │ ├── localToLocal.as
│ │ ├── moveBy.as
│ │ ├── moveTo.as
│ │ ├── originalHeight.as
│ │ ├── originalWidth.as
│ │ ├── relativePos.as
│ │ ├── removeAllChildren.as
│ │ ├── removeAllChildrenByType.as
│ │ ├── removeChild.as
│ │ ├── removeChildAt.as
│ │ ├── scheduleForNextFrame.as
│ │ ├── sendBackward.as
│ │ ├── sendToBack.as
│ │ ├── setProperties.as
│ │ ├── showChildren.as
│ │ ├── stopAllTimelines.as
│ │ ├── sumProps.as
│ │ ├── traceChildren.as
│ │ ├── transformToFitRect.as
│ │ └── wait.as
│ ├── draw/
│ │ ├── createCircleShape.as
│ │ ├── createEllipseShape.as
│ │ ├── createRectangleShape.as
│ │ ├── drawRoundRect.as
│ │ └── drawWedge.as
│ ├── error/
│ │ └── getStackTrace.as
│ ├── frame/
│ │ ├── addFrameScript.as
│ │ ├── getFrameNumberForLabel.as
│ │ └── removeFrameScript.as
│ ├── fullscreen/
│ │ └── toggleFullScreen.as
│ ├── garbageCollection/
│ │ └── gc.as
│ ├── geom/
│ │ ├── Direction.as
│ │ ├── Ellipse.as
│ │ ├── Point3d.as
│ │ ├── Side.as
│ │ ├── angle.as
│ │ ├── cartesianToPolarCoordinates.as
│ │ ├── getRectangleCenter.as
│ │ ├── getRectanglePerimeter.as
│ │ ├── polarToCartesianCoordinates.as
│ │ ├── randomPoint.as
│ │ ├── reverseRectangle.as
│ │ ├── rotatePoint.as
│ │ ├── roundPoint.as
│ │ ├── simplifyAngle.as
│ │ └── trimAngle.as
│ ├── html/
│ │ ├── a.as
│ │ ├── br.as
│ │ ├── entities.as
│ │ ├── img.as
│ │ ├── p.as
│ │ ├── span.as
│ │ └── styledTag.as
│ ├── js/
│ │ └── callJSFunction.as
│ ├── library/
│ │ ├── getBitmapDataFromLibrary.as
│ │ ├── getClassFromLibrary.as
│ │ └── getClipFromLibrary.as
│ ├── load/
│ │ ├── calculateBps.as
│ │ ├── calculateBufferPercent.as
│ │ ├── calculateKBps.as
│ │ ├── calculateMillisecondsUntilBuffered.as
│ │ └── checkDomain.as
│ ├── location/
│ │ ├── getDomain.as
│ │ ├── getLocationName.as
│ │ ├── isDomain.as
│ │ ├── locationNames.as
│ │ ├── openURL.as
│ │ ├── openWindow.as
│ │ └── windowNames.as
│ ├── math/
│ │ ├── Percent.as
│ │ ├── Range.as
│ │ ├── expressAsOdds.as
│ │ └── gcd.as
│ ├── mvc/
│ │ ├── AbstractController.as
│ │ ├── AbstractModel.as
│ │ ├── AbstractView.as
│ │ ├── IController.as
│ │ ├── IModel.as
│ │ └── IView.as
│ ├── number/
│ │ ├── addLeadingZeroes.as
│ │ ├── clamp.as
│ │ ├── createStepsBetween.as
│ │ ├── fastMax2.as
│ │ ├── fastMin2.as
│ │ ├── format.as
│ │ ├── getOrdinalSuffix.as
│ │ ├── getWeightedAverage.as
│ │ ├── hexChars.as
│ │ ├── insertCommas.as
│ │ ├── interpolate.as
│ │ ├── isBetween.as
│ │ ├── isEqual.as
│ │ ├── isEven.as
│ │ ├── isInteger.as
│ │ ├── isNegative.as
│ │ ├── isOdd.as
│ │ ├── isPositive.as
│ │ ├── isPrime.as
│ │ ├── isRoughlyEqual.as
│ │ ├── loopIndex.as
│ │ ├── map.as
│ │ ├── max.as
│ │ ├── min.as
│ │ ├── normalize.as
│ │ ├── pad.as
│ │ ├── randomIntegerWithinRange.as
│ │ ├── randomSign.as
│ │ ├── randomWithinRange.as
│ │ ├── rol.as
│ │ ├── ror.as
│ │ ├── round.as
│ │ ├── roundDecimalToPlace.as
│ │ └── toHex.as
│ ├── object/
│ │ ├── assign.as
│ │ ├── clone.as
│ │ ├── combine.as
│ │ ├── contains.as
│ │ ├── copy.as
│ │ ├── create.as
│ │ ├── createInstance.as
│ │ ├── getKeys.as
│ │ ├── hasAnyProperties.as
│ │ ├── inspect.as
│ │ ├── isEmpty.as
│ │ ├── isNull.as
│ │ ├── isSimple.as
│ │ ├── isUniformPropertyType.as
│ │ ├── merge.as
│ │ ├── numProperties.as
│ │ ├── toArray.as
│ │ └── toString.as
│ ├── range/
│ │ ├── center.as
│ │ ├── isInRange.as
│ │ ├── randomRangeDate.as
│ │ ├── randomRangeSet.as
│ │ └── resolve.as
│ ├── ratio/
│ │ ├── defineRect.as
│ │ ├── heightToWidth.as
│ │ ├── scale.as
│ │ ├── scaleHeight.as
│ │ ├── scaleToFill.as
│ │ ├── scaleToFit.as
│ │ ├── scaleWidth.as
│ │ └── widthToHeight.as
│ ├── string/
│ │ ├── addSlashes.as
│ │ ├── afterFirst.as
│ │ ├── afterLast.as
│ │ ├── arrayList.as
│ │ ├── beforeFirst.as
│ │ ├── beforeLast.as
│ │ ├── beginsWith.as
│ │ ├── between.as
│ │ ├── constants.as
│ │ ├── convertBytesString.as
│ │ ├── detectBr.as
│ │ ├── endsWith.as
│ │ ├── equals.as
│ │ ├── firstToUpper.as
│ │ ├── getLettersFromString.as
│ │ ├── htmlDecode.as
│ │ ├── htmlEncode.as
│ │ ├── ltrim.as
│ │ ├── numberToString.as
│ │ ├── padLeft.as
│ │ ├── padRight.as
│ │ ├── randomCharacters.as
│ │ ├── randomLowercaseCharacters.as
│ │ ├── randomNumberString.as
│ │ ├── randomSequence.as
│ │ ├── randomSpecialCharacters.as
│ │ ├── remove.as
│ │ ├── removeExtraWhitespace.as
│ │ ├── removeSpaces.as
│ │ ├── removeTabs.as
│ │ ├── repeat.as
│ │ ├── replace.as
│ │ ├── reverse.as
│ │ ├── reverseWords.as
│ │ ├── rtrim.as
│ │ ├── sanitizeNull.as
│ │ ├── search.as
│ │ ├── slashUnsafeChars.as
│ │ ├── stringHasValue.as
│ │ ├── stringsAreEqual.as
│ │ ├── stripSlashes.as
│ │ ├── stripTags.as
│ │ ├── toDoubleQuote.as
│ │ ├── toNumeric.as
│ │ ├── toSingleQuote.as
│ │ ├── toTitleCase.as
│ │ ├── trim.as
│ │ ├── trimCamel.as
│ │ ├── truncate.as
│ │ ├── truncate2.as
│ │ ├── wordCount.as
│ │ └── xtrim.as
│ ├── swf/
│ │ └── SWFReader.as
│ ├── textField/
│ │ ├── TextFieldWrapper.as
│ │ ├── clearFields.as
│ │ ├── createField.as
│ │ ├── formatFields.as
│ │ ├── getUsableFonts.as
│ │ ├── hideFields.as
│ │ ├── revealFields.as
│ │ ├── setFormattedText.as
│ │ ├── setStyledText.as
│ │ ├── setTextColor.as
│ │ ├── setTextFont.as
│ │ ├── setTextLeading.as
│ │ ├── setTextLetterSpacing.as
│ │ ├── setTextSpaceWidth.as
│ │ ├── styleFields.as
│ │ ├── truncateMultilineText.as
│ │ └── truncateText.as
│ ├── type/
│ │ ├── PACKAGE_CLASS_SEPARATOR.as
│ │ ├── convertFullyQualifiedName.as
│ │ ├── describeInheritance.as
│ │ ├── describeMethods.as
│ │ ├── describeProperties.as
│ │ ├── describeType.as
│ │ ├── forInstance.as
│ │ ├── forName.as
│ │ ├── getClass.as
│ │ ├── getClassByName.as
│ │ ├── getClassName.as
│ │ ├── getDisplayObjectClass.as
│ │ ├── getFullyQualifiedName.as
│ │ ├── getFullyQualifiedSuperClassname.as
│ │ ├── getName.as
│ │ ├── getNameFromFullyQualifiedName.as
│ │ ├── getPropertyType.as
│ │ ├── getSuperClassName.as
│ │ ├── getType.as
│ │ ├── isInterface.as
│ │ ├── isPassedByValue.as
│ │ ├── isType.as
│ │ ├── newInstance.as
│ │ ├── registerType.as
│ │ ├── strictIs.as
│ │ └── typeCache.as
│ ├── validation/
│ │ ├── US_STATE_ABBREVIATIONS.as
│ │ ├── encodeCreditCardNumber.as
│ │ ├── getCreditCardProvider.as
│ │ ├── isBlank.as
│ │ ├── isCreditCard.as
│ │ ├── isEmail.as
│ │ ├── isNumeric.as
│ │ ├── isPOBox.as
│ │ ├── isURL.as
│ │ ├── isUSAStateAbbreviation.as
│ │ ├── isValidCreditCardNumber.as
│ │ ├── isValidEmailAddress.as
│ │ ├── isValidExpirationDate.as
│ │ └── isValidPhoneNumber.as
│ └── xml/
│ ├── XMLConstants.as
│ ├── getNextSibling.as
│ ├── getPreviousSibling.as
│ ├── getSiblingByIndex.as
│ └── isValidXML.as
└── test/
├── UtilsTestRunner.as
├── UtilsTestSuite.as
└── utils/
├── align/
│ ├── AlignLeftTest.as
│ ├── AlignRightTest.as
│ └── alignCenterTest.as
├── date/
│ ├── GetNextDayTest.as
│ ├── GetPrevDayTest.as
│ ├── GetTimeElapsedStringTest.as
│ └── calendar/
│ └── CalendarTests.as
├── dictionary/
│ └── CircularDictionaryTest.as
├── display/
│ └── FindAncestorTest.as
├── geom/
│ ├── CartesianToPolarCoordinatesTest.as
│ └── PolarToCartesianCoordinatesTest.as
├── number/
│ ├── ClampTest.as
│ └── ToHexTest.as
├── object/
│ ├── CreateInstanceTest.as
│ ├── CreateTest.as
│ ├── MergeTest.as
│ ├── cloneTest.as
│ └── containsTest.as
├── range/
│ └── RandomRangeDateTest.as
├── string/
│ ├── numberToStringTest.as
│ └── stringHasValueTest.as
├── type/
│ ├── IsPassedByValueTest.as
│ └── StrictIsTest.as
├── validation/
│ ├── IsValidEmailAddressTest.as
│ ├── encodeCreditCardNumberTest.as
│ ├── getCreditCardProviderTest.as
│ ├── isBlankTest.as
│ ├── isCreditCardTest.as
│ ├── isEmailTest.as
│ ├── isNumericTest.as
│ ├── isPOBoxTest.as
│ ├── isUSAStateAbbreviationTest.as
│ ├── isUrlTest.as
│ ├── isValidCreditCardNumberTest.as
│ ├── isValidExpirationDateTest.as
│ └── isValidPhoneNumberTest.as
└── xml/
├── GetNextSiblingTest.as
├── GetPreviousSiblingTest.as
├── GetSiblingByIndexTest.as
└── isValidXMLTest.as
Condensed preview — 569 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (515K chars).
[
{
"path": ".gitignore",
"chars": 227,
"preview": "src/FlexUnitApplication.mxml\nsrc/FlexUnitCompilerApplication.mxml\ntarget\nbin/FlexUnitApplication.swf\nbin-debug\nbin-relea"
},
{
"path": "Contribution Guidelines.md",
"chars": 9741,
"preview": "#Contribution Guidelines\n\nAs developers, many of us have created our own working set of classes and functions for handli"
},
{
"path": "Libraries to integrate.md",
"chars": 334,
"preview": "* Sekati - [http://code.google.com/p/sekati/](http://code.google.com/p/sekati/)\n* BumpSlide - [http://code.google.com/p/"
},
{
"path": "NOTES.md",
"chars": 6160,
"preview": "# as3-utils\n\n# ISSUES\n\n- parameter names are not descriptive\n- variable names are not descriptive\n- nomenclature is inco"
},
{
"path": "README.md",
"chars": 2225,
"preview": "# as3-utils\n\nActionScript 3 Utilities and Object Extensions provided as reusable package-level functions that solve comm"
},
{
"path": "TODO.md",
"chars": 329,
"preview": "# TODO\n\n- combine with [asx](http://github.com/drewbourne/asx)\n- attribute all functions to proper authors\n- check utils"
},
{
"path": "build/pmd/LICENSE.txt",
"chars": 1711,
"preview": " Copyright (c) 2009, Adobe Systems, Incorporated\n All rights reserved.\n\n Redistribution and use in source and"
},
{
"path": "build.properties",
"chars": 261,
"preview": "project.name=as3-utils\n\nbuild.groupId=as3\nbuild.artifactId=as3-utils\nbuild.version=0.1\nbuild.artifact=${build.artifactId"
},
{
"path": "build.xml",
"chars": 7261,
"preview": "<?xml version=\"1.0\"?>\n<project\n\tname=\"as3-utils\"\n\tbasedir=\".\"\n\tdefault=\"package\">\n\n\t<!--\n\t\tas3-utils\n\t\t\n\t\tusage: \n\t\t\t$ a"
},
{
"path": "res/flex-formatter.properties",
"chars": 13438,
"preview": "#FlexFormatter settings\n#Sat Apr 10 22:47:59 EST 2010\nASRearr_UseModifierOrder_Function=true\nActionscript.useBraceStyle="
},
{
"path": "src/.gitignore",
"chars": 24,
"preview": "FlexUnitApplication.mxml"
},
{
"path": "src/deprecated/.gitignore",
"chars": 2,
"preview": " \n"
},
{
"path": "src/deprecated/confine.as",
"chars": 476,
"preview": "package deprecated\n{\n\t[Deprecated(replacement=\"utils.number.clamp\")]\n\t\n\t/**\n\t * Restricts the <code>value</code> to the "
},
{
"path": "src/deprecated/constrain.as",
"chars": 855,
"preview": "package deprecated\n{\n\t[Deprecated(replacement=\"utils.number.clamp\")]\n\t\n\t/**\n\t Determines if value falls within a range"
},
{
"path": "src/deprecated/getURL.as",
"chars": 552,
"preview": "package deprecated {\n\timport flash.net.URLRequest;\n\timport flash.net.navigateToURL;\n\n\n\n\t[Deprecated(replacement=\"utils.l"
},
{
"path": "src/deprecated/randomBoolean.as",
"chars": 654,
"preview": "package deprecated {\n\t[Deprecated(replacement=\"utils.boolean.randomChance\")]\n\n\n\t/**\n\t * Returns a Boolean.\n\t * Example c"
},
{
"path": "src/deprecated/randomRangeFloat.as",
"chars": 263,
"preview": "package deprecated {\n\t[Deprecated(replacement=\"utils.number.randomWithinRange\")]\n\n\n\t/**\n\t * Returns a random float numbe"
},
{
"path": "src/deprecated/randomRangeInt.as",
"chars": 283,
"preview": "package deprecated {\n\t[Deprecated(replacement=\"utils.number.randomIntegerWithinRange\")]\n\n\n\n\t/**\n\t * Returns a random int"
},
{
"path": "src/utils/align/alignCenter.as",
"chars": 248,
"preview": "package utils.align {\n\timport flash.display.DisplayObject;\n\n\t/**\n\t * Center align object to target.\n\t */\n\tpublic functio"
},
{
"path": "src/utils/align/alignLeft.as",
"chars": 1253,
"preview": "package utils.align\n{\n\t/**\n\t * Aligns all the target DisplayObjects by their left edge to the left-most target. \n\t *\n\t *"
},
{
"path": "src/utils/align/alignRight.as",
"chars": 1266,
"preview": "package utils.align\n{\n\t/**\n\t * Aligns all the target DisplayObjects by their left edge to the left-most target. \n\t *\n\t *"
},
{
"path": "src/utils/align/alignToRectangleBottom.as",
"chars": 850,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t Aligns a DisplayObjec"
},
{
"path": "src/utils/align/alignToRectangleCenter.as",
"chars": 727,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t Aligns a DisplayObjec"
},
{
"path": "src/utils/align/alignToRectangleCenterMiddle.as",
"chars": 730,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t Aligns a DisplayObjec"
},
{
"path": "src/utils/align/alignToRectangleLeft.as",
"chars": 850,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t Aligns a DisplayObjec"
},
{
"path": "src/utils/align/alignToRectangleMiddle.as",
"chars": 727,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t Aligns a DisplayObjec"
},
{
"path": "src/utils/align/alignToRectangleRight.as",
"chars": 854,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t Aligns a DisplayObjec"
},
{
"path": "src/utils/align/alignToRectangleTop.as",
"chars": 842,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t Aligns a DisplayObjec"
},
{
"path": "src/utils/align/getPositionToTheRightOf.as",
"chars": 645,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\t\n\timport utils.ratio.widthToHeight;\n\t\t\n\t/**\n\t * Gets the pos"
},
{
"path": "src/utils/align/getPositionUnder.as",
"chars": 569,
"preview": "package utils.align {\n\timport flash.display.DisplayObject;\n\n\t/**\n\t * Gets the position under an object based on its heig"
},
{
"path": "src/utils/align/gridAlignSpaceNumber.as",
"chars": 1449,
"preview": "package utils.align\n{\n\t/**\n\t * Aligns the items in the array in a grid based on the number of rows and columns.\n\t * Uses"
},
{
"path": "src/utils/align/gridAlignSpaceNumberGap.as",
"chars": 1092,
"preview": "package utils.align\n{\n\t/**\n\t * Aligns the items in the array in a grid based on the number of rows and columns.\n\t * Uses"
},
{
"path": "src/utils/align/horizontalAlign.as",
"chars": 614,
"preview": "package utils.align {\n\n\n\n\t/**\n\t * Convenient horizontal align method with optional alignment argument\n\t * @example <list"
},
{
"path": "src/utils/align/horizontalAlignNoSpace.as",
"chars": 440,
"preview": "package utils.align\n{\n\t/**\n\t * Aligns each item horizontally to the one above it.\n\t * Uses no spacing.\n\t *\n\t * @example "
},
{
"path": "src/utils/align/horizontalAlignSpaceArray.as",
"chars": 597,
"preview": "package utils.align {\n\n\n\n\t/**\n\t * Aligns each item in the array to the one preceding it.\n\t * Uses the correlating positi"
},
{
"path": "src/utils/align/horizontalAlignSpaceNumber.as",
"chars": 579,
"preview": "package utils.align\n{\n\t/**\n\t * Aligns the items in the array horizontally to each the one preceding it in the array.\n\t *"
},
{
"path": "src/utils/align/interpolate.as",
"chars": 915,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\n\t/**\n\t * interpolate the DisplayObject at weight t == (0 <"
},
{
"path": "src/utils/align/interpolateMultiX.as",
"chars": 762,
"preview": "package utils.align\n{\n\t/**\n\t * interpolate multiple DisplayObjects at multiple weights at t == (0 less or equal t less o"
},
{
"path": "src/utils/align/interpolateMultiY.as",
"chars": 769,
"preview": "package utils.align\n{\n\t/**\n\t * interpolate multiple DisplayObjects at multiple weights at t == (0 less or equal t less o"
},
{
"path": "src/utils/align/interpolateX.as",
"chars": 563,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\n\t/**\n\t * interpolate the DisplayObject at weight t to the re"
},
{
"path": "src/utils/align/interpolateY.as",
"chars": 659,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\n\t/**\n\t * interpolate the DisplayObject at weight t == (0 les"
},
{
"path": "src/utils/align/verticalAlign.as",
"chars": 667,
"preview": "package utils.align {\n\n\n\n\t/**\n\t * Convenient vertical align method with optional alignment argument\n\t * @example <listin"
},
{
"path": "src/utils/align/verticalAlignNoSpace.as",
"chars": 442,
"preview": "package utils.align\n{\n\t/**\n\t * Aligns each item vertically to the one above it.\n\t * Uses no spacing.\n\t *\n\t * @example <l"
},
{
"path": "src/utils/align/verticalAlignSpaceArray.as",
"chars": 600,
"preview": "package utils.align {\n\n\n\n\t/**\n\t * Aligns each item in the array to the one preceding it.\n\t * Uses the correlating positi"
},
{
"path": "src/utils/align/verticalAlignSpaceNumber.as",
"chars": 753,
"preview": "package utils.align\n{\n\timport flash.text.TextField;\n\n\t/**\n\t * Aligns the items in the array vertically to each the one p"
},
{
"path": "src/utils/align/xAlignCenter.as",
"chars": 867,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n import flash.geom.Point;\n import flash.geom.Rectangle;"
},
{
"path": "src/utils/align/xAlignLeft.as",
"chars": 222,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\n\t/**\n\t * Horizontal left align object to target.\n\t */\n\tpubli"
},
{
"path": "src/utils/align/xAlignRight.as",
"chars": 241,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\n\t/**\n\t * Horizontal right align object to target.\n\t */\n\tpubl"
},
{
"path": "src/utils/align/yAlignCenter.as",
"chars": 815,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n import flash.geom.Point;\n import flash.geom.Rectangle;"
},
{
"path": "src/utils/align/yAlignLeft.as",
"chars": 221,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\n\t/**\n\t * Vertical left align object to target.\n\t */\n\tpublic"
},
{
"path": "src/utils/align/yAlignRight.as",
"chars": 241,
"preview": "package utils.align\n{\n\timport flash.display.DisplayObject;\n\n\t/**\n\t * Vertical right align object to target.\n\t */\n\tpublic"
},
{
"path": "src/utils/array/addItemsAt.as",
"chars": 885,
"preview": "package utils.array\n{\n\t/**\n\t Modifies original Array by adding all the elements from another Array at a specified posi"
},
{
"path": "src/utils/array/arrayContainsValue.as",
"chars": 567,
"preview": "package utils.array\n{\n\t/**\n\t * Determines whether the specified array contains the specified value.\n\t *\n\t * "
},
{
"path": "src/utils/array/arraysAreEqual.as",
"chars": 808,
"preview": "package utils.array {\n\t/**\n\t * Compares two arrays and returns a boolean indicating whether the arrays\n\t * c"
},
{
"path": "src/utils/array/average.as",
"chars": 504,
"preview": "package utils.array\n{\n\t/**\n\t Averages the values in <code>inArray</code>.\n\n\t @param inArray: Array composed only of "
},
{
"path": "src/utils/array/contains.as",
"chars": 680,
"preview": "package utils.array\n{\n\t/**\n\t Finds out how many instances of <code>item</code> Array contains.\n\n\t @param inArray: Ar"
},
{
"path": "src/utils/array/containsAll.as",
"chars": 675,
"preview": "package utils.array\n{\n\t/**\n\t Determines if Array contains all items.\n\n\t @param inArray: Array to search for <code>it"
},
{
"path": "src/utils/array/containsAny.as",
"chars": 724,
"preview": "package utils.array\n{\n\t/**\n\t Determines if Array <code>inArray</code> contains any element of Array <code>items</code>"
},
{
"path": "src/utils/array/copyArray.as",
"chars": 606,
"preview": "package utils.array\n{\n\t/**\n\t * Creates a copy of the specified array.\n\t *\n\t * Note that the array returned i"
},
{
"path": "src/utils/array/createUniqueCopy.as",
"chars": 912,
"preview": "package utils.array\n{\n\t/**\n\t * Create a new array that only contains unique instances of objects\n\t * in the "
},
{
"path": "src/utils/array/equals.as",
"chars": 554,
"preview": "package utils.array\n{\n\t/**\n\t Determines if two Arrays contain the same objects at the same index.\n\n\t @param first: F"
},
{
"path": "src/utils/array/getHighestValue.as",
"chars": 483,
"preview": "package utils.array\n{\n\t/**\n\t Finds the highest value in <code>inArray</code>.\n\n\t @param inArray: Array composed only"
},
{
"path": "src/utils/array/getIndexOfDifference.as",
"chars": 924,
"preview": "package utils.array\n{\n\t/**\n\t Compares two Arrays and finds the first index where they differ.\n\n\t @param first: First"
},
{
"path": "src/utils/array/getItemByKey.as",
"chars": 575,
"preview": "package utils.array\n{\n\t/**\n\t Returns the first element that matches <code>match</code> for the property <code>key</cod"
},
{
"path": "src/utils/array/getItemByType.as",
"chars": 458,
"preview": "package utils.array\n{\n\t/**\n\t Returns the first element that is compatible with a specific data type, clazz, or interfa"
},
{
"path": "src/utils/array/getItemsByKey.as",
"chars": 566,
"preview": "package utils.array\n{\n\t/**\n\t Returns every element that matches <code>match</code> for the property <code>key</code>.\n"
},
{
"path": "src/utils/array/getItemsByType.as",
"chars": 484,
"preview": "package utils.array\n{\n\t/**\n\t Returns every element that is compatible with a specific data type, clazz, or interface.\n"
},
{
"path": "src/utils/array/getLowestValue.as",
"chars": 461,
"preview": "package utils.array\n{\n\t/**\n\t Finds the lowest value in <code>inArray</code>.\n\n\t @param inArray: Array composed only "
},
{
"path": "src/utils/array/getRandomElement.as",
"chars": 240,
"preview": "package utils.array {\n\timport utils.number.randomIntegerWithinRange;\n\n\t/**\n\t * Returns a random element from an array.\n\t"
},
{
"path": "src/utils/array/randomize.as",
"chars": 765,
"preview": "package utils.array\n{\n\timport utils.number.randomIntegerWithinRange;\n\n\t/**\n\t Creates new Array composed of passed Arra"
},
{
"path": "src/utils/array/removeDuplicates.as",
"chars": 591,
"preview": "package utils.array\n{\n\t/**\n\t Creates new Array composed of only the non-identical elements of passed Array.\n\n\t @para"
},
{
"path": "src/utils/array/removeItem.as",
"chars": 764,
"preview": "package utils.array\n{\n\t/**\n\t Modifies original Array by removing all items that are identical to the specified item.\n\n"
},
{
"path": "src/utils/array/removeItems.as",
"chars": 768,
"preview": "package utils.array\n{\n\t/**\n\t Removes only the specified items in an Array.\n\n\t @param tarArray: Array to remove speci"
},
{
"path": "src/utils/array/removeValueFromArray.as",
"chars": 549,
"preview": "package utils.array {\n\t/**\n\t * Remove all instances of the specified value from the array,\n\t *\n\t * @param ar"
},
{
"path": "src/utils/array/retainItems.as",
"chars": 765,
"preview": "package utils.array\n{\n\t/**\n\t Retains only the specified items in an Array.\n\n\t @param tarArray: Array to remove non s"
},
{
"path": "src/utils/array/sum.as",
"chars": 503,
"preview": "package utils.array\n{\n\t/**\n\t Adds all items in <code>inArray</code> and returns the value.\n\n\t @param inArray: Array "
},
{
"path": "src/utils/assert/assertArrayContains.as",
"chars": 405,
"preview": "package utils.assert\n{\n\t/**\n\t * Assert that the array contains the passed in item.\n\t */\n\tpublic function assertArrayCont"
},
{
"path": "src/utils/assert/assertArrayItemsTypeOf.as",
"chars": 598,
"preview": "package utils.assert\n{\n\t/**\n\t * Assert that all items in the array are of the given type.\n\t *\n\t * @param array the array"
},
{
"path": "src/utils/assert/assertDictionaryKeysTypeOf.as",
"chars": 523,
"preview": "package utils.assert\n{\n\timport flash.utils.Dictionary;\n\n\t/**\n\t * Assert that the given Dictionary contains only keys of "
},
{
"path": "src/utils/assert/assertHasText.as",
"chars": 688,
"preview": "package utils.assert\n{\n\timport utils.validation.isBlank;\n\n\t/**\n\t * Assert that the given String has valid text content; "
},
{
"path": "src/utils/assert/assertInstanceOf.as",
"chars": 697,
"preview": "package utils.assert\n{\n\t/**\n\t * Assert that an object is an instance of a certain type..\n\t * <pre class=\"code\">Assert.in"
},
{
"path": "src/utils/assert/assertIsTrue.as",
"chars": 286,
"preview": "package utils.assert\n{\n\tpublic function assertIsTrue(expression:Boolean, message:String = \"\"):void\n\t{\n\t\tif (!expression)"
},
{
"path": "src/utils/assert/assertNotNull.as",
"chars": 631,
"preview": "package utils.assert\n{\n\t/**\n\t * Assert that an object is <code>null</code>.\n\t * <pre class=\"code\">Assert.isNull(value, \""
},
{
"path": "src/utils/assert/assertState.as",
"chars": 481,
"preview": "package utils.assert\n{\n\t/**\n\t * Assert a boolean expression to be true. If false, an IllegalStateError is thrown.\n\t * @p"
},
{
"path": "src/utils/boolean/randomBoolean.as",
"chars": 182,
"preview": "package utils.boolean\n{\n\t/**\n\t * Randomly returns either true or false.\n\t * \n\t * @author Mims Wright\n\t */\n\tpublic functi"
},
{
"path": "src/utils/boolean/randomChance.as",
"chars": 258,
"preview": "package utils.boolean\n{\n\t/**\n\t * Randomly returns true \"percent\"% of the time (where percent is a decimal between 0.0 an"
},
{
"path": "src/utils/capabilities/getPlayerInfo.as",
"chars": 484,
"preview": "package utils.capabilities\n{\n\timport flash.system.Capabilities;\n\n\t/**\n\t * Returns a player and environment info string.\n"
},
{
"path": "src/utils/capabilities/isAirApplication.as",
"chars": 385,
"preview": "package utils.capabilities {\n\timport flash.system.Capabilities;\n\n\n\n\t/**\n\t * Determines if the runtime environment is an "
},
{
"path": "src/utils/capabilities/isIDE.as",
"chars": 403,
"preview": "package utils.capabilities {\n\timport flash.system.Capabilities;\n\n\n\n\t/**\n\t * Determines if the SWF is running in the IDE."
},
{
"path": "src/utils/capabilities/isMac.as",
"chars": 237,
"preview": "package utils.capabilities\n{\n\timport flash.system.Capabilities;\n\n\t/**\n\t * Indicates whether the running OS is a Mac\n\t * "
},
{
"path": "src/utils/capabilities/isPC.as",
"chars": 235,
"preview": "package utils.capabilities\n{\n\timport flash.system.Capabilities;\n\n\t/**\n\t * Indicates whether the running OS is a PC\n\t * @"
},
{
"path": "src/utils/capabilities/isPlugin.as",
"chars": 415,
"preview": "package utils.capabilities {\n\timport flash.system.Capabilities;\n\n\n\n\t/**\n\t * Determines if the SWF is running in a browse"
},
{
"path": "src/utils/capabilities/isStandAlone.as",
"chars": 382,
"preview": "package utils.capabilities {\n\timport flash.system.Capabilities;\n\n\n\n\t/**\n\t * Determines if the SWF is running in the Stan"
},
{
"path": "src/utils/capabilities/isWeb.as",
"chars": 528,
"preview": "package utils.capabilities {\n\timport flash.display.DisplayObject;\n\n\n\n\t/**\n\t * Determines if the SWF is being served on t"
},
{
"path": "src/utils/color/HSLtoHSV.as",
"chars": 311,
"preview": "package utils.color\n{\n\t/**\n\t * Convert HSL to HSV using RGB conversions: color preservation may be dubious.\n\t */\n\tpublic"
},
{
"path": "src/utils/color/HSLtoRGB.as",
"chars": 555,
"preview": "package utils.color\n{\n\t/**\n\t * Convert HSL values to RGB values.\n\t * @param hue 0 to 360.\n\t * @param l"
},
{
"path": "src/utils/color/HSVtoHSL.as",
"chars": 303,
"preview": "package utils.color\n{\n\t/**\n\t * Convert HSV to HLS using RGB conversions: color preservation may be dubious.\n\t */\n\tpublic"
},
{
"path": "src/utils/color/HSVtoRGB.as",
"chars": 464,
"preview": "package utils.color\n{\n\t/**\n\t * Convert HSV values to RGB values.\n\t * @param hue on 0 to 360 scale.\n\t *"
},
{
"path": "src/utils/color/HueToRGB.as",
"chars": 908,
"preview": "package utils.color\n{\n\t/**\n\t * Convert hue to RGB values using a linear transformation.\n\t * @param min of R,G,B.\n\t * @"
},
{
"path": "src/utils/color/RGBToHue.as",
"chars": 1117,
"preview": "package utils.color\n{\n\timport utils.range.center;\n\n\t/**\n\t * Convert RGB values to a hue using a linear transformation.\n\t"
},
{
"path": "src/utils/color/RGBtoHSL.as",
"chars": 991,
"preview": "package utils.color {\n\n\n\n\t/**\n\t * Convert an RGB Hexadecimal value to HSL values\n\t * @param red 0 - 1 scale.\n\t"
},
{
"path": "src/utils/color/RGBtoHSV.as",
"chars": 888,
"preview": "package utils.color\n{\n\t/**\n\t * Convert RGB values to HSV values.\n\t * @param red 0 to 1 scale.\n\t * @param green"
},
{
"path": "src/utils/color/averageBlue.as",
"chars": 609,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t * Sample & average "
},
{
"path": "src/utils/color/averageColorProperty.as",
"chars": 1667,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t * @private\n\t *\n\t * Samp"
},
{
"path": "src/utils/color/averageGreen.as",
"chars": 612,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t * Sample & average "
},
{
"path": "src/utils/color/averageHue.as",
"chars": 606,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t * Sample & average "
},
{
"path": "src/utils/color/averageLightness.as",
"chars": 624,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t * Sample & average "
},
{
"path": "src/utils/color/averageRed.as",
"chars": 607,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t * Sample & average "
},
{
"path": "src/utils/color/averageSaturation.as",
"chars": 629,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t * Sample & average "
},
{
"path": "src/utils/color/averageValue.as",
"chars": 617,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t * Sample & average "
},
{
"path": "src/utils/color/changeContrast.as",
"chars": 517,
"preview": "package utils.color {\n\timport utils.number.clamp;\n\n\n\n\t/**\n\t * Change the contrast of a hexadecimal Number by a certain i"
},
{
"path": "src/utils/color/getARGB.as",
"chars": 642,
"preview": "package utils.color\n{\n\t/**\n\t Converts a 32-bit ARGB color value into an ARGB object.\n\n\t @param color: The 32-bit ARG"
},
{
"path": "src/utils/color/getColor.as",
"chars": 763,
"preview": "package utils.color\n{\n\t/**\n\t Converts a series of individual RGB(A) values to a 32-bit ARGB color value.\n\n\t @param r"
},
{
"path": "src/utils/color/getColorFromDisplayObject.as",
"chars": 890,
"preview": "package utils.color\n{\n\timport flash.display.BitmapData;\n\timport flash.display.DisplayObject;\n\n\timport utils.number.clamp"
},
{
"path": "src/utils/color/getHexStringFromARGB.as",
"chars": 1000,
"preview": "package utils.color {\n\n\n\n\t/**\n\t Converts a 32-bit ARGB color value into a hexadecimal String representation.\n\t @param a "
},
{
"path": "src/utils/color/getHexStringFromRGB.as",
"chars": 834,
"preview": "package utils.color {\n\n\n\n\t/**\n\t Converts an RGB color value into a hexadecimal String representation.\n\t @param r A uint "
},
{
"path": "src/utils/color/getRGB.as",
"chars": 551,
"preview": "package utils.color\n{\n\t/**\n\t Converts a 24-bit RGB color value into an RGB object.\n\n\t @param color: The 24-bit RGB c"
},
{
"path": "src/utils/color/getTransform.as",
"chars": 593,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.ColorTransform;\n\n\t/**\n\t * Returns the tran"
},
{
"path": "src/utils/color/interpolateColor.as",
"chars": 1698,
"preview": "package utils.color\n{\n\timport flash.geom.ColorTransform;\n\n\timport utils.math.Percent;\n\timport utils.number.interpolate;\n"
},
{
"path": "src/utils/color/invertColor.as",
"chars": 341,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\n\t/**\n\t * Inverts the color of the DisplayObject.\n\t */\n\tpubli"
},
{
"path": "src/utils/color/randomColor.as",
"chars": 201,
"preview": "package utils.color\n{\n\t/**\n\t * Returns a random color between 0x000000 and 0xFFFFFF\n\t * \n\t * @author Mims Wright\n\t */\n\tp"
},
{
"path": "src/utils/color/resetColor.as",
"chars": 288,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\n\t/**\n\t * Reset the color of the DisplayObject to its origina"
},
{
"path": "src/utils/color/setARGB.as",
"chars": 212,
"preview": "package utils.color\n{\n\tpublic function setARGB(a:Number, r:Number, g:Number, b:Number):uint\n\t{\n\t\tvar argb:uint = 0;\n\t\tar"
},
{
"path": "src/utils/color/setColor.as",
"chars": 374,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.ColorTransform;\n\n\t/**\n\t * Set the (A)RGB <"
},
{
"path": "src/utils/color/setTransform.as",
"chars": 1192,
"preview": "package utils.color\n{\n\timport flash.display.DisplayObject;\n\timport flash.geom.ColorTransform;\n\n\t/**\n\t * Set ColorTransfo"
},
{
"path": "src/utils/color/toColor.as",
"chars": 309,
"preview": "package utils.color\n{\n\t/**\n\t * Parse a String representation of a color (hex or html) to uint.\n\t */\n\tpublic function toC"
},
{
"path": "src/utils/color/toGrayscale.as",
"chars": 282,
"preview": "package utils.color\n{\n\tpublic function toGrayscale(hex:uint):uint\n\t{\n\t\tvar color:Object = getARGB(hex);\n\t\tvar c:Number ="
},
{
"path": "src/utils/color/toHTML.as",
"chars": 234,
"preview": "package utils.color {\n\n\n\n\t/**\n\t * Convert a hexadecimal number to a string representation with HTML notation: <code>#rrg"
},
{
"path": "src/utils/color/toHexString.as",
"chars": 247,
"preview": "package utils.color {\n\n\n\n\t/**\n\t * Convert a hexadecimal number to a string representation with ECMAScript notation: <cod"
},
{
"path": "src/utils/color/toRGBComponents.as",
"chars": 251,
"preview": "package utils.color {\n\n\n\n\t/**\n\t * Convert individual R,G,B values to a hexadecimal value.\n\t */\n\tpublic function toRGBCom"
},
{
"path": "src/utils/conversion/bitsToBytes.as",
"chars": 219,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts bits to bytes.\n\n\t @param bits: The number of bits.\n\t @return Returns th"
},
{
"path": "src/utils/conversion/bitsToKilobits.as",
"chars": 231,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts bits to kilobits.\n\n\t @param bits: The number of bits.\n\t @return Returns"
},
{
"path": "src/utils/conversion/bitsToKilobytes.as",
"chars": 233,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts bits to kilobytes.\n\n\t @param bits: The number of bits.\n\t @return Return"
},
{
"path": "src/utils/conversion/bytesToBits.as",
"chars": 222,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts bytes to bits.\n\n\t @param bytes: The number of bytes.\n\t @return Returns "
},
{
"path": "src/utils/conversion/bytesToKilobits.as",
"chars": 236,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts bytes to kilobits.\n\n\t @param bytes: The number of bytes.\n\t @return Retu"
},
{
"path": "src/utils/conversion/bytesToKilobytes.as",
"chars": 240,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts bytes to kilobytes.\n\n\t @param bytes: The number of bytes.\n\t @return Ret"
},
{
"path": "src/utils/conversion/daysToHours.as",
"chars": 220,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts days to hours.\n\n\t @param days: The number of days.\n\t @return Returns th"
},
{
"path": "src/utils/conversion/daysToMilliseconds.as",
"chars": 274,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts days to milliseconds.\n\n\t @param days: The number of days.\n\t @return Ret"
},
{
"path": "src/utils/conversion/daysToMinutes.as",
"chars": 250,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts days to minutes.\n\n\t @param days: The number of days.\n\t @return Returns "
},
{
"path": "src/utils/conversion/daysToSeconds.as",
"chars": 254,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts days to seconds.\n\n\t @param days: The number of days.\n\t @return Returns "
},
{
"path": "src/utils/conversion/degreesToRadians.as",
"chars": 257,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts degrees to radians.\n\n\t @param degrees: The number of degrees.\n\t @return"
},
{
"path": "src/utils/conversion/hoursToDays.as",
"chars": 223,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts hours to days.\n\n\t @param hours: The number of hours.\n\t @return Returns "
},
{
"path": "src/utils/conversion/hoursToMilliseconds.as",
"chars": 281,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts hours to milliseconds.\n\n\t @param hours: The number of hours.\n\t @return "
},
{
"path": "src/utils/conversion/hoursToMinutes.as",
"chars": 232,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts hours to minutes.\n\n\t @param hours: The number of hours.\n\t @return Retur"
},
{
"path": "src/utils/conversion/hoursToSeconds.as",
"chars": 261,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts hours to seconds.\n\n\t @param hours: The number of hours.\n\t @return Retur"
},
{
"path": "src/utils/conversion/kilobitsToBits.as",
"chars": 243,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts kilobits to bits.\n\n\t @param kilobits: The number of kilobits.\n\t @return"
},
{
"path": "src/utils/conversion/kilobitsToBytes.as",
"chars": 245,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts kilobits to bytes.\n\n\t @param kilobits: The number of kilobits.\n\t @retur"
},
{
"path": "src/utils/conversion/kilobitsToKilobytes.as",
"chars": 256,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts kilobits to kilobytes.\n\n\t @param kilobytes: The number of kilobits.\n\t @"
},
{
"path": "src/utils/conversion/kilobytesToBits.as",
"chars": 249,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts kilobytes to bits.\n\n\t @param kilobytes: The number of kilobytes.\n\t @ret"
},
{
"path": "src/utils/conversion/kilobytesToBytes.as",
"chars": 252,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts kilobytes to bytes.\n\n\t @param kilobytes: The number of kilobytes.\n\t @re"
},
{
"path": "src/utils/conversion/kilobytesToKilobits.as",
"chars": 258,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts kilobytes to kilobits.\n\n\t @param kilobytes: The number of kilobytes.\n\t "
},
{
"path": "src/utils/conversion/millisecondsToDays.as",
"chars": 295,
"preview": "package utils.conversion\n{\n\n\t/**\n\t Converts milliseconds to days.\n\n\t @param milliseconds: The number of milliseconds"
},
{
"path": "src/utils/conversion/millisecondsToHours.as",
"chars": 302,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts milliseconds to hours.\n\n\t @param milliseconds: The number of milliseconds"
},
{
"path": "src/utils/conversion/millisecondsToMinutes.as",
"chars": 310,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts milliseconds to minutes.\n\n\t @param milliseconds: The number of millisecon"
},
{
"path": "src/utils/conversion/millisecondsToSeconds.as",
"chars": 276,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts milliseconds to seconds.\n\n\t @param milliseconds: The number of millisecon"
},
{
"path": "src/utils/conversion/minutesToDays.as",
"chars": 259,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts minutes to days.\n\n\t @param minutes: The number of minutes.\n\t @return Re"
},
{
"path": "src/utils/conversion/minutesToHours.as",
"chars": 238,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts minutes to hours.\n\n\t @param minutes: The number of minutes.\n\t @return R"
},
{
"path": "src/utils/conversion/minutesToMilliseconds.as",
"chars": 295,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts minutes to milliseconds.\n\n\t @param minutes: The number of minutes.\n\t @r"
},
{
"path": "src/utils/conversion/minutesToSeconds.as",
"chars": 244,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts minutes to seconds.\n\n\t @param minutes: The number of minutes.\n\t @return"
},
{
"path": "src/utils/conversion/radiansToDegrees.as",
"chars": 257,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts radians to degrees.\n\n\t @param radians: The number of radians.\n\t @return"
},
{
"path": "src/utils/conversion/secondsToDays.as",
"chars": 259,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts seconds to days.\n\n\t @param seconds: The number of seconds.\n\t @return Re"
},
{
"path": "src/utils/conversion/secondsToHours.as",
"chars": 268,
"preview": "package utils.conversion\n{\n\n\t/**\n\t Converts seconds to hours.\n\n\t @param seconds: The number of seconds.\n\t @return "
},
{
"path": "src/utils/conversion/secondsToMilliseconds.as",
"chars": 261,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts seconds to milliseconds.\n\n\t @param seconds: The number of seconds.\n\t @r"
},
{
"path": "src/utils/conversion/secondsToMinutes.as",
"chars": 244,
"preview": "package utils.conversion\n{\n\t/**\n\t Converts seconds to minutes.\n\n\t @param seconds: The number of seconds.\n\t @return"
},
{
"path": "src/utils/cookie/getCookie.as",
"chars": 675,
"preview": "package utils.cookie\n{\n\timport flash.external.ExternalInterface;\n\n\tpublic function getCookie(cookieName:String):String\n\t"
},
{
"path": "src/utils/cookie/setCookie.as",
"chars": 355,
"preview": "package utils.cookie\n{\n\timport flash.external.ExternalInterface;\n\n\tpublic function setCookie(cookieName:String, cookieVa"
},
{
"path": "src/utils/date/Calendar.as",
"chars": 753,
"preview": "/**\n * User: John Lindquist\n * Date: 3/16/11\n * Time: 11:27 AM\n */\npackage utils.date\n{\n\t/**\n\t * Calendar is an exceptio"
},
{
"path": "src/utils/date/TimeRelationships.as",
"chars": 1180,
"preview": "package utils.date\n{\n\n\tpublic class TimeRelationships\n\t{\n\t\t//\n\t\t// Milliseconds\n\t\t//\n\n\t\tpublic static const YEAR_IN_MILL"
},
{
"path": "src/utils/date/Timezone.as",
"chars": 2317,
"preview": "package utils.date\n{\n\t/*\n\t* Need to discuss how to refactor timezone logic into better utils\n\t* \n\t* This class currently"
},
{
"path": "src/utils/date/addWeeks.as",
"chars": 124,
"preview": "package utils.date\n{\n\tpublic function addWeeks(date:Date, weeks:uint):Date\n\t{\n\t\tdate.date += weeks * 7;\n\t\treturn date;\n"
},
{
"path": "src/utils/date/ceil.as",
"chars": 411,
"preview": "package utils.date\n{\n\t/**\n\t * Returns the rounded up date where the time is 12:00am.\n\t * If a date is not provided, the "
},
{
"path": "src/utils/date/clone.as",
"chars": 183,
"preview": "package utils.date\n{\n\tpublic function clone(date:Date):Date\n\t{\n\t\treturn new Date(date.fullYear, date.month, date.date, d"
},
{
"path": "src/utils/date/compareDates.as",
"chars": 806,
"preview": "package utils.date\n{\n\t/**\n\t * Compares two dates and returns an integer depending on their relationship.\n\t *\n\t * "
},
{
"path": "src/utils/date/dayAbbrNames.as",
"chars": 115,
"preview": "package utils.date {\n\n\n\tpublic const dayAbbrNames:Array = [ \"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\" ];\n\n\n}\n"
},
{
"path": "src/utils/date/dayNames.as",
"chars": 135,
"preview": "package utils.date\n{\n\tpublic const dayNames:Array = [ \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", "
},
{
"path": "src/utils/date/equals.as",
"chars": 409,
"preview": "package utils.date\n{\n\t/**\n\t Determines if two Dates are the same time.\n\n\t @param first: First Date to compare to <co"
},
{
"path": "src/utils/date/floor.as",
"chars": 396,
"preview": "package utils.date\n{\n\t/**\n\t * Returns the rounded down date where the time is 12:00am.\n\t * If a date is not provided, th"
},
{
"path": "src/utils/date/formatDate.as",
"chars": 12492,
"preview": "package utils.date {\n\timport utils.conversion.minutesToSeconds;\n\timport utils.number.addLeadingZeroes;\n\timport utils.num"
},
{
"path": "src/utils/date/formatWeekOf.as",
"chars": 241,
"preview": "package utils.date\n{\n\tpublic function formatWeekOf(date:Date):String\n\t{\n\t\tdate = getLastSunday(date);\n\n\t\tvar string:Stri"
},
{
"path": "src/utils/date/getAMPM.as",
"chars": 685,
"preview": "package utils.date\n{\n\t/**\n\t * Returns a string indicating whether the date represents a time in the\n\t * ante"
},
{
"path": "src/utils/date/getCountdownUntil.as",
"chars": 1374,
"preview": "package utils.date\n{\n\timport utils.conversion.daysToHours;\n\timport utils.conversion.hoursToMinutes;\n\timport utils.conver"
},
{
"path": "src/utils/date/getDayAbbrName.as",
"chars": 276,
"preview": "package utils.date {\n\n\n\n\t/**\n\t * Returns the English abbreviation name of the provided day.\n\t * @param day the index of "
},
{
"path": "src/utils/date/getDayAsString.as",
"chars": 223,
"preview": "package utils.date\n{\n\tpublic function getDayAsString(day:Number):String\n\t{\n\t\tvar dayNamesFull:Array = new Array('Sunday'"
},
{
"path": "src/utils/date/getDayName.as",
"chars": 260,
"preview": "package utils.date\n{\n\t/**\n\t * Returns the English name of the provided day.\n\t * @param day the index of the day, where z"
},
{
"path": "src/utils/date/getDayOfTheYear.as",
"chars": 423,
"preview": "package utils.date\n{\n\t/**\n\t Gets the current day out of the total days in the year (starting from 0).\n\n\t @param d: D"
},
{
"path": "src/utils/date/getDaysInMonth.as",
"chars": 543,
"preview": "package utils.date\n{\n\t/**\n\t Finds the number of days in the given month.\n\n\t @param year: The full year.\n\t @param m"
},
{
"path": "src/utils/date/getEarliestDate.as",
"chars": 670,
"preview": "package utils.date\n{\n\t/**\n\t * Compares dates and returns the latest one.\n\t *\n\t * @param dates that will be c"
},
{
"path": "src/utils/date/getFormattedDifferenceFromUTC.as",
"chars": 666,
"preview": "package utils.date {\n\timport utils.conversion.minutesToHours;\n\timport utils.number.addLeadingZeroes;\n\n\n\n\t/**\n\t * Formats"
},
{
"path": "src/utils/date/getInternetTime.as",
"chars": 488,
"preview": "package utils.date\n{\n\timport utils.conversion.minutesToHours;\n\timport utils.conversion.secondsToHours;\n\n\t/**\n\t Convert"
},
{
"path": "src/utils/date/getLastMonday.as",
"chars": 122,
"preview": "package utils.date\n{\n\tpublic function getLastMonday(date:Date):Date\n\t{\n\t\tdate.date -= (date.day - 1);\n\n\t\treturn date;\n\t}"
},
{
"path": "src/utils/date/getLastSunday.as",
"chars": 148,
"preview": "package utils.date\n{\n\tpublic function getLastSunday(date:Date):Date\n\t{\n\t\tvar temp:Date = clone(date);\n\n\t\ttemp.date -= te"
},
{
"path": "src/utils/date/getLatestDate.as",
"chars": 656,
"preview": "package utils.date\n{\n\t/**\n\t * Compares dates and returns the latest one.\n\t *\n\t * @param dates that will be c"
},
{
"path": "src/utils/date/getMeridiem.as",
"chars": 414,
"preview": "package utils.date\n{\n\t/**\n\t Determines if time is Ante meridiem or Post meridiem.\n\n\t @param hours: The hour to find "
},
{
"path": "src/utils/date/getMonthAbbrName.as",
"chars": 260,
"preview": "package utils.date {\n\n\n\n\t/**\n\t * Returns the English abbreviation name of the provided month.\n\t * @param month the index"
},
{
"path": "src/utils/date/getMonthName.as",
"chars": 236,
"preview": "package utils.date\n{\n\t/**\n\t * Returns the English name of the provided month.\n\t * @param month the index of the month, s"
},
{
"path": "src/utils/date/getNextDay.as",
"chars": 666,
"preview": "package utils.date\n{\n /** Returns the next calender date following the provided Date.\n\t * If no Date is provided, the"
},
{
"path": "src/utils/date/getPreviousDay.as",
"chars": 677,
"preview": "package utils.date\n{\n\t/** Returns the previous calender date to the provided Date.\n\t * If no Date is provided, the curre"
},
{
"path": "src/utils/date/getShortHour.as",
"chars": 749,
"preview": "package utils.date\n{\n\t/**\n\t * Returns a short hour (0 - 12) represented by the specified date.\n\t *\n\t * If th"
},
{
"path": "src/utils/date/getShortYear.as",
"chars": 682,
"preview": "package utils.date\n{\n\t/**\n\t * Returns a two digit representation of the year represented by the\n\t * specifie"
},
{
"path": "src/utils/date/getStartOfWeek.as",
"chars": 191,
"preview": "package utils.date\n{\n\tpublic function getStartOfWeek(date:Date):Date\n\t{\n\t\tvar temp:Date = clone(date);\n\n\t\ttemp.date -= t"
}
]
// ... and 369 more files (download for full content)
About this extraction
This page contains the full source code of the as3/as3-utils GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 569 files (431.8 KB), approximately 134.4k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.