You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2016/01/11 21:55:54 UTC
[10/20] git commit: [flex-asjs] [refs/heads/mavenfolders] -
rename/restructure folders for maven
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a903508e/frameworks/projects/Core/as/src/org/apache/flex/utils/CSSContainerUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/CSSContainerUtils.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/CSSContainerUtils.as
deleted file mode 100644
index 868faec..0000000
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/CSSContainerUtils.as
+++ /dev/null
@@ -1,194 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.utils
-{
-import org.apache.flex.core.ValuesManager;
-import org.apache.flex.geom.Rectangle;
-
-/**
- * The CSSContainerUtils class is a utility class that computes the values
- * containers often need to know like border widths and padding styles.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
-public class CSSContainerUtils
-{
- /**
- * Compute the width/thickness of the four border edges.
- *
- * @param object The object with style values.
- * @param quick True to assume all four edges have the same widths.
- * @return A Rectangle representing the four sides.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function getBorderMetrics(object:Object, quick:Boolean = false):Rectangle
- {
- var borderThickness:Object = ValuesManager.valuesImpl.getValue(object, "border-width");
- var borderStyle:Object = ValuesManager.valuesImpl.getValue(object, "border-style");
- var border:Object = ValuesManager.valuesImpl.getValue(object, "border");
- var borderOffset:Number;
- if (borderStyle == "none")
- borderOffset = 0;
- else if (borderThickness != null)
- {
- if (borderThickness is String)
- borderOffset = CSSUtils.toNumber(borderThickness as String, object.width);
- else
- borderOffset = Number(borderThickness);
- if( isNaN(borderOffset) ) borderOffset = 0;
- }
- else // no style and/or no width
- {
- border = ValuesManager.valuesImpl.getValue(object,"border");
- if (border != null)
- {
- if (border is Array)
- {
- borderOffset = CSSUtils.toNumber(border[0], object.width);
- borderStyle = border[1];
- }
- else if (border == "none")
- borderOffset = 0;
- else if (border is String)
- borderOffset = CSSUtils.toNumber(border as String, object.width);
- else
- borderOffset = Number(border);
- }
- else // no border style set at all so default to none
- borderOffset = 0;
- }
-
- if (quick)
- return new Rectangle(borderOffset, borderOffset, 0, 0);
-
- var widthTop:int = borderOffset;
- var widthLeft:int = borderOffset;
- var widthBottom:int = borderOffset;
- var widthRight:int = borderOffset;
- var value:*;
- var values:Array;
- var n:int;
- value = ValuesManager.valuesImpl.getValue(object, "border-top");
- if (value != null)
- {
- if (value is Array)
- values = value as Array;
- else
- values = value.split(" ");
- n = values.length;
- widthTop = CSSUtils.toNumber(values[0]);
- }
- value = ValuesManager.valuesImpl.getValue(object, "border-left");
- if (value != null)
- {
- if (value is Array)
- values = value as Array;
- else
- values = value.split(" ");
- n = values.length;
- widthLeft = CSSUtils.toNumber(values[0]);
- }
- value = ValuesManager.valuesImpl.getValue(object, "border-bottom");
- if (value != null)
- {
- if (value is Array)
- values = value as Array;
- else
- values = value.split(" ");
- n = values.length;
- widthBottom = CSSUtils.toNumber(values[0]);
- }
- value = ValuesManager.valuesImpl.getValue(object, "border-right");
- if (value != null)
- {
- if (value is Array)
- values = value as Array;
- else
- values = value.split(" ");
- n = values.length;
- widthRight = CSSUtils.toNumber(values[0]);
- }
- // do the math so consumer can use
- // left, right, top, bottom properties and not width/height
- return new Rectangle(widthLeft, widthTop, widthRight - widthLeft, widthTop - widthBottom);
- }
-
- /**
- * Compute the width/thickness of the four padding sides.
- *
- * @param object The object with style values.
- * @return A Rectangle representing the padding on each of the four sides.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function getPaddingMetrics(object:Object):Rectangle
- {
- var paddingLeft:Object;
- var paddingTop:Object;
- var paddingRight:Object;
- var paddingBottom:Object;
-
- var padding:Object = ValuesManager.valuesImpl.getValue(object, "padding");
- paddingLeft = ValuesManager.valuesImpl.getValue(object, "padding-left");
- paddingTop = ValuesManager.valuesImpl.getValue(object, "padding-top");
- paddingRight = ValuesManager.valuesImpl.getValue(object, "padding-right");
- paddingBottom = ValuesManager.valuesImpl.getValue(object, "padding-bottom");
- var pl:Number = CSSUtils.getLeftValue(paddingLeft, padding, object.width);
- var pt:Number = CSSUtils.getTopValue(paddingTop, padding, object.height);
- var pr:Number = CSSUtils.getRightValue(paddingRight, padding, object.width);
- var pb:Number = CSSUtils.getBottomValue(paddingBottom, padding, object.height);
-
- // do the math so consumer can use
- // left, right, top, bottom properties and not width/height
- return new Rectangle(pl, pt, pr - pl, pb - pt);
- }
-
-
- /**
- * Combine padding and border. Often used in non-containers.
- *
- * @param object The object with style values.
- * @return A Rectangle representing the padding and border on each of the four sides.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function getBorderAndPaddingMetrics(object:Object):Rectangle
- {
- var borderMetrics:Rectangle = getBorderMetrics(object);
- var paddingMetrics:Rectangle = getPaddingMetrics(object);
- return new Rectangle(borderMetrics.left + paddingMetrics.left,
- borderMetrics.top + paddingMetrics.top,
- borderMetrics.width + paddingMetrics.width,
- borderMetrics.height + paddingMetrics.height);
- }
-}
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a903508e/frameworks/projects/Core/as/src/org/apache/flex/utils/CSSUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/CSSUtils.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/CSSUtils.as
deleted file mode 100644
index 770c428..0000000
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/CSSUtils.as
+++ /dev/null
@@ -1,328 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.utils
-{
-
- /**
- * The CSSUtils class is a collection of static functions that provide utility
- * features for managing CSS values.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public class CSSUtils
- {
- /**
- * @private
- */
- public function CSSUtils()
- {
- throw new Error("CSSUtils should not be instantiated.");
- }
-
- /**
- * Converts a String to number.
- *
- * @param str The String.
- * @param reference A Number that will be used to convert percentages.
- *
- * @return Number.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function toNumber(str:String, reference:Number = 0):Number
- {
- var c:int = str.indexOf("px");
- if (c != -1)
- return Number(str.substr(0, c));
-
- c = str.indexOf("%");
- if (c != -1)
- return Number(str.substr(0, c)) * reference / 100;
-
- return Number(str);
- }
-
- /**
- * Converts a value describing a color to a uint
- *
- * @param value The value.
- *
- * @return uint of the color.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function toColor(value:Object):uint
- {
- return toColorWithAlpha(value) & 0xFFFFFF;
- }
-
- /**
- * Converts a value describing a color and alpha in a uint
- *
- * @param value The value.
- *
- * @return uint of the color.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- * @flexjsignorecoercion String
- */
- public static function toColorWithAlpha(value:Object):uint
- {
- if (!(value is String))
- return uint(value) | 0xFF000000; // css parser converted #rrggbb without alpha channel
-
- var c:int;
- var c2:int;
-
- var stringValue:String = value as String;
- if (stringValue.charAt(0) == '#')
- {
- if (stringValue.length == 4)
- return uint("0x" + stringValue.charAt(1) + stringValue.charAt(1) +
- stringValue.charAt(2) + stringValue.charAt(2) +
- stringValue.charAt(3) + stringValue.charAt(3));
- if (stringValue.length == 7)
- return uint("0xFF" + stringValue.substr(1));
- return uint("0x" + stringValue.substr(1));
- }
- else if ((c = stringValue.indexOf("rgb(")) != -1)
- {
- c2 = stringValue.indexOf(")");
- stringValue = stringValue.substring(c + 4, c2);
- var parts3:Array = stringValue.split(",");
- return (0xFF000000 +
- uint(parts3[0]) << 16 +
- uint(parts3[1]) << 8 +
- uint(parts3[2]));
- }
- else if ((c = stringValue.indexOf("rgba(")) != -1)
- {
- c2 = stringValue.indexOf(")");
- stringValue = stringValue.substring(c + 4, c2);
- var parts4:Array = stringValue.split(",");
- return (uint(parts4[3]) << 24 +
- uint(parts3[0]) << 16 +
- uint(parts3[1]) << 8 +
- uint(parts3[2]));
- }
-
- if (colorMap.hasOwnProperty(stringValue))
- return colorMap[stringValue];
- return uint(stringValue);
- }
-
- /**
- * Computes paddingLeft or marginLeft.
- *
- * @param value The value of padding-left or margin-left.
- * @param values The value of padding or margin.
- * @param reference A Number that will be used to convert percentages.
- *
- * @return Number.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- * @flexjsignorecoercion String
- */
- public static function getLeftValue(value:Object, values:Object, reference:Number = NaN):Number
- {
- if (value is Number)
- return value as Number;
-
- if (values is Number)
- return values as Number;
-
- if (value != null)
- return toNumber(value as String, reference);
- if (values == null)
- return 0;
- if (values is Array)
- {
- var arr:Array = values as Array;
- var n:int = arr.length;
- // shouldn't be n == 1. values would not be an array
- var index:int = n < 3 ? 1 : 3;
- value = arr[index];
- if (value is String)
- return toNumber(value as String, reference);
- return value as Number;
- }
- return toNumber(values as String, reference);
- }
-
- /**
- * Computes paddingRight or marginRight.
- *
- * @param value The value of padding-right or margin-right.
- * @param values The value of padding or margin.
- * @param reference A Number that will be used to convert percentages.
- *
- * @return Number.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- * @flexjsignorecoercion String
- */
- public static function getRightValue(value:Object, values:Object, reference:Number = NaN):Number
- {
- if (value is Number)
- return value as Number;
-
- if (values is Number)
- return values as Number;
-
- if (value != null)
- return toNumber(value as String, reference);
- if (values == null)
- return 0;
- if (values is Array)
- {
- var arr:Array = values as Array;
- value = arr[1];
- if (value is String)
- return toNumber(value as String, reference);
- return value as Number;
- }
- return toNumber(values as String, reference);
- }
-
- /**
- * Computes paddingTop or marginTop.
- *
- * @param value The value of padding-top or margin-top.
- * @param values The value of padding or margin.
- * @param reference A Number that will be used to convert percentages.
- *
- * @return Number.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- * @flexjsignorecoercion String
- */
- public static function getTopValue(value:Object, values:Object, reference:Number = NaN):Number
- {
- if (value is Number)
- return value as Number;
-
- if (values is Number)
- return values as Number;
-
- if (value != null)
- return toNumber(value as String, reference);
- if (values == null)
- return 0;
- if (values is Array)
- {
- var arr:Array = values as Array;
- value = arr[0];
- if (value is String)
- return toNumber(value as String, reference);
- return value as Number;
- }
- return toNumber(values as String, reference);
- }
-
- /**
- * Computes paddingBottom or marginBottom.
- *
- * @param value The value of padding-bottom or margin-bottom.
- * @param values The value of padding or margin.
- * @param reference A Number that will be used to convert percentages.
- *
- * @return Number.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- * @flexjsignorecoercion String
- */
- public static function getBottomValue(value:Object, values:Object, reference:Number = NaN):Number
- {
- if (value is Number)
- return value as Number;
-
- if (values is Number)
- return values as Number;
-
- if (value != null)
- return toNumber(value as String, reference);
- if (values == null)
- return 0;
- if (values is Array)
- {
- var arr:Array = values as Array;
- var n:int = arr.length;
- // shouldn't be n == 1. values would not be an array
- var index:int = n == 2 ? 0 : 2;
- value = arr[index];
- if (value is String)
- return toNumber(value as String, reference);
- return value as Number;
- }
- return toNumber(values as String, reference);
- }
-
- /**
- * The map of color names to uints.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static var colorMap:Object = {
- transparent: 0,
- white: 0xFFFFFFFF,
- silver: 0xFFC0C0C0,
- gray: 0xFF808080,
- black: 0xFF000000,
- red: 0xFFFF0000,
- maroon: 0xFF800000,
- yellow: 0xFFFFFF00,
- olive: 0xFF808000,
- lime: 0xFF00FF00,
- green: 0xFF008000,
- aqua: 0xFF00FFFF,
- teal: 0xFF008080,
- blue: 0xFF0000FF,
- navy: 0xFF000080,
- fuchsia: 0xFFFF00FF,
- purple: 0xFF800080
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a903508e/frameworks/projects/Core/as/src/org/apache/flex/utils/EffectTimer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/EffectTimer.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/EffectTimer.as
deleted file mode 100644
index 3e557d6..0000000
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/EffectTimer.as
+++ /dev/null
@@ -1,136 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.utils
-{
-COMPILE::AS3
-{
- import flash.events.EventDispatcher;
- import flash.events.TimerEvent;
- import flash.utils.Timer;
- import flash.utils.getTimer;
-}
-COMPILE::JS
-{
- import org.apache.flex.events.EventDispatcher;
-}
-import org.apache.flex.core.IEffectTimer;
-import org.apache.flex.core.ValuesManager;
-import org.apache.flex.events.ValueEvent;
-
-//--------------------------------------
-// Events
-//--------------------------------------
-
-/**
- * Dispatched as requested via the delay and
- * repeat count parameters in the constructor.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
-[Event(name="update", type="org.apache.flex.events.ValueEvent")]
-
-/**
- * The Timer class dispatches events based on a delay
- * and repeat count.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
-public class EffectTimer extends EventDispatcher implements IEffectTimer
-{
- /**
- * Constructor.
- *
- * @param delay The number of milliseconds
- * to wait before dispatching the event.
- * @param repeatCount The number of times to dispatch
- * the event. If 0, keep dispatching forever.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public function EffectTimer()
- {
- interval = ValuesManager.valuesImpl.getValue(this, "effectTimerInterval");
- COMPILE::AS3
- {
- timer = new flash.utils.Timer(interval);
- timer.addEventListener("timer", timerHandler);
- }
- }
-
- private var interval:int;
-
- COMPILE::AS3
- private var timer:flash.utils.Timer;
-
- COMPILE::JS
- private var timerInterval:Number;
-
- public function start():int
- {
- COMPILE::AS3
- {
- timer.start();
- return getTimer();
- }
- COMPILE::JS
- {
- timerInterval =
- setInterval(timerHandler, interval);
- var d:Date = new Date();
- return d.getTime();
- }
- }
-
- public function stop():void
- {
- COMPILE::AS3
- {
- timer.stop();
- }
- COMPILE::JS
- {
- clearInterval(timerInterval);
- timerInterval = -1;
- }
- }
-
- COMPILE::AS3
- private function timerHandler(event:flash.events.TimerEvent):void
- {
- event.updateAfterEvent();
- dispatchEvent(new ValueEvent("update", false, false, getTimer()));
- }
-
- COMPILE::JS
- private function timerHandler():void
- {
- var d:Date = new Date();
- dispatchEvent(new ValueEvent('update', false, false, d.getTime()));
- }
-}
-}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a903508e/frameworks/projects/Core/as/src/org/apache/flex/utils/Language.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/Language.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/Language.as
deleted file mode 100644
index 0627820..0000000
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/Language.as
+++ /dev/null
@@ -1,357 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.utils
-{
-
- [ExcludeClass]
- COMPILE::AS3
- public class Language {}
-
- COMPILE::JS
- {
- import goog.bind;
- import goog.global;
- }
-
- /**
- * @flexjsignoreimport goog.bind
- * @flexjsignoreimport goog.global
- */
- COMPILE::JS
- public class Language
- {
-
- //--------------------------------------
- // Static Property
- //--------------------------------------
-
- //--------------------------------------
- // Static Function
- //--------------------------------------
-
- /**
- * as()
- *
- * @param leftOperand The lefthand operand of the
- * binary as operator in AS3.
- * @param rightOperand The righthand operand of the
- * binary operator in AS3.
- * @param coercion The cast is a coercion,
- * throw exception if it fails.
- * @return Returns the lefthand operand if it is of the
- * type of the righthand operand, otherwise null.
- */
- static public function as(leftOperand:Object, rightOperand:Object, coercion:* = null):Object
- {
- var error:Error, itIs:Boolean, message:String;
-
- coercion = (coercion !== undefined) ? coercion : false;
-
- itIs = Language.is(leftOperand, rightOperand);
-
- if (!itIs && coercion)
- {
- message = 'Type Coercion failed';
-
- if (TypeError)
- {
- error = new TypeError(message);
- }
- else
- {
- error = new Error(message);
- }
- throw error;
- }
-
- return (itIs) ? leftOperand : null;
- }
-
-
- /**
- * int()
- *
- * @param value The value to be cast.
- * @return {number}
- */
- static public function _int(value:Number):Number
- {
- return value >> 0;
- }
-
- /**
- * is()
- *
- * @param leftOperand The lefthand operand of the
- * binary as operator in AS3.
- * @param rightOperand The righthand operand of the
- * binary operator in AS3.
- * @return {boolean}
- */
- static public function is(leftOperand:Object, rightOperand:Object):Boolean
- {
- var superClass:Object;
-
- if (leftOperand == null || rightOperand == null)
- return false;
-
- if (leftOperand instanceof rightOperand)
- return true;
- if (rightOperand === Object)
- return true; // every value is an Object in ActionScript except null and undefined (caught above)
-
- if (typeof leftOperand === 'string')
- return rightOperand === String;
-
- if (typeof leftOperand === 'number')
- return rightOperand === Number;
-
- if (typeof leftOperand === 'boolean')
- return rightOperand === Boolean;
- if (rightOperand === Array)
- return Array.isArray(leftOperand);
-
- if (leftOperand.FLEXJS_CLASS_INFO === undefined)
- return false; // could be a function but not an instance
-
- if (leftOperand.FLEXJS_CLASS_INFO.interfaces)
- {
- if (checkInterfaces(leftOperand, rightOperand))
- {
- return true;
- }
- }
-
- superClass = leftOperand.constructor;
- superClass = superClass.superClass_;
-
- if (superClass)
- {
- while (superClass && superClass.FLEXJS_CLASS_INFO)
- {
- if (superClass.FLEXJS_CLASS_INFO.interfaces)
- {
- if (checkInterfaces(superClass, rightOperand))
- {
- return true;
- }
- }
- superClass = superClass.constructor;
- superClass = superClass.superClass_;
- }
- }
-
- return false;
- }
-
- /**
- * Helper function for is()
- */
- private static function checkInterfaces(leftOperand:*, rightOperand:*):Boolean
- {
- var i:int, interfaces:Array;
-
- interfaces = leftOperand.FLEXJS_CLASS_INFO.interfaces;
- for (i = interfaces.length - 1; i > -1; i--) {
- if (interfaces[i] === rightOperand) {
- return true;
- }
-
- if (interfaces[i].prototype.FLEXJS_CLASS_INFO.interfaces) {
- var isit:Boolean = checkInterfaces(interfaces[i].prototype, rightOperand);
- if (isit) return true;
- }
- }
-
- return false;
- }
-
- /**
- * Implementation of "classDef is Class"
- */
- public function isClass(classDef:*):Boolean
- {
- return typeof classDef === 'function'
- && classDef.prototype
- && classDef.prototype.constructor === classDef;
- }
-
- /**
- * Implementation of "classDef as Class"
- */
- public function asClass(classDef:*):Class
- {
- return isClass(classDef) ? classDef : null;
- }
-
- /**
- * postdecrement handles foo--
- *
- * @param obj The object with the getter/setter.
- * @param prop The name of a property.
- * @return {number}
- */
- static public function postdecrement(obj:Object, prop:String):int
- {
- var value:int = obj[prop];
- obj[prop] = value - 1;
- return value;
- }
-
- /**
- * postincrement handles foo++
- *
- * @param obj The object with the getter/setter.
- * @param prop The name of a property.
- * @return {number}
- */
- static public function postincrement(obj:Object, prop:String):int
- {
- var value:int = obj[prop];
- obj[prop] = value + 1;
- return value;
- }
-
- /**
- * predecrement handles --foo
- *
- * @param obj The object with the getter/setter.
- * @param prop The name of a property.
- * @return {number}
- */
- static public function predecrement(obj:Object, prop:String):int
- {
- var value:int = obj[prop] - 1;
- obj[prop] = value;
- return value;
- }
-
- /**
- * preincrement handles ++foo
- *
- * @param obj The object with the getter/setter.
- * @param prop The name of a property.
- * @return {number}
- */
- static public function preincrement(obj:Object, prop:String):int
- {
- var value:int = obj[prop] + 1;
- obj[prop] = value;
- return value;
- }
-
- /**
- * superGetter calls the getter on the given class' superclass.
- *
- * @param clazz The class.
- * @param pthis The this pointer.
- * @param prop The name of the getter.
- * @return {Object}
- */
- static public function superGetter(clazz:Object, pthis:Object, prop:String):Object
- {
- var superClass:Object = clazz.superClass_;
- var superdesc:Object = Object.getOwnPropertyDescriptor(superClass, prop);
-
- while (superdesc == null)
- {
- superClass = superClass.constructor;
- superClass = superClass.superClass_;
- superdesc = Object.getOwnPropertyDescriptor(superClass, prop);
- }
- return superdesc.get.call(pthis);
- }
-
- /**
- * superSetter calls the setter on the given class' superclass.
- *
- * @param clazz The class.
- * @param pthis The this pointer.
- * @param prop The name of the getter.
- * @param value The value.
- */
- static public function superSetter(clazz:Object, pthis:Object, prop:String, value:Object):void
- {
- var superClass:Object = clazz.superClass_;
- var superdesc:Object = Object.getOwnPropertyDescriptor(superClass, prop);
-
- while (superdesc == null)
- {
- superClass = superClass.constructor;
- superClass = superClass.superClass_;
- superdesc = Object.getOwnPropertyDescriptor(superClass, prop);
- }
- superdesc.set.apply(pthis, [value]);
- }
-
- static public function trace(...rest):void
- {
- var theConsole:*;
- var windowConsole:* = window.console;
-
- theConsole = goog.global.console;
-
- if (theConsole === undefined && windowConsole !== undefined)
- theConsole = windowConsole;
-
- try
- {
- if (theConsole && theConsole.log)
- {
- theConsole.log.apply(theConsole, rest);
- }
- }
- catch (e:Error)
- {
- // ignore; at least we tried ;-)
- }
- }
-
- /**
- * uint()
- *
- * @param value The value to be cast.
- * @return {number}
- */
- static public function uint(value:Number):Number
- {
- return value >>> 0;
- }
-
- /**
- * caches closures and returns the one closure
- *
- * @param fn The method on the instance.
- * @param object The instance.
- * @param boundMethodName The name to use to cache the closure.
- * @return The closure.
- */
- static public function closure(fn:Function, object:Object, boundMethodName:String):Function {
- if (object.hasOwnProperty(boundMethodName)) {
- return object[boundMethodName];
- }
- var boundMethod:Function = goog.bind(fn, object);
- Object.defineProperty(object, boundMethodName, {
- value: boundMethod
- });
- return boundMethod;
- };
-
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a903508e/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as
deleted file mode 100644
index c69b550..0000000
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as
+++ /dev/null
@@ -1,463 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.utils
-{
-
-COMPILE::AS3
-{
- import flash.display.DisplayObject;
-}
-
-import org.apache.flex.core.IBead;
-import org.apache.flex.core.IContainer;
-import org.apache.flex.core.IDocument;
-import org.apache.flex.core.IMXMLDocument;
-import org.apache.flex.core.IParent;
-import org.apache.flex.core.IStrand;
-import org.apache.flex.events.Event;
-import org.apache.flex.events.IEventDispatcher;
-
-COMPILE::JS
-{
- import goog.bind;
- import org.apache.flex.core.IUIBase;
-}
-
-/**
- * The MXMLDataInterpreter class is the class that interprets the
- * encoded information generated by the compiler that describes
- * the contents of an MXML document.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- * @flexjsignoreimport goog.bind
- */
-public class MXMLDataInterpreter
-{
- /**
- * Constructor. All methods are static so should not be instantiated.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public function MXMLDataInterpreter()
- {
- super();
- }
-
-
- /**
- * Generates an object based on the encoded data.
- *
- * @param document The MXML document. If the object has an id
- * it will be assigned in this document in this method.
- * @param data The encoded data.
- * @return The object.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function generateMXMLObject(document:Object, data:Array):Object
- {
- var i:int = 0;
- var cls:Class = data[i++];
- var comp:Object = new cls();
-
- if (comp is IStrand)
- initializeStrandBasedObject(document, null, comp, data, i);
- else
- {
- var m:int;
- var j:int;
- var name:String;
- var simple:*;
- var value:Object;
- var id:String;
-
- m = data[i++]; // num props
- for (j = 0; j < m; j++)
- {
- name = data[i++];
- simple = data[i++];
- value = data[i++];
- if (simple == null)
- value = generateMXMLArray(document, null, value as Array);
- else if (simple == false)
- value = generateMXMLObject(document, value as Array);
- if (name == "id")
- id = value as String;
- if (name == "document" && !comp.document)
- comp.document = document;
- else if (name == "_id")
- id = value as String; // and don't assign to comp
- else if (name == "id")
- {
- // not all objects have to have their own id property
- try {
- comp["id"] = value;
- } catch (e:Error)
- {
-
- }
- }
- else
- comp[name] = value;
- }
- if (id)
- document[id] = comp;
-
- if (comp is IDocument)
- comp.setDocument(document, id);
- }
- return comp;
- }
-
- /**
- * Generates an Array of objects based on the encoded data.
- *
- * @param document The MXML document. If the object has an id
- * it will be assigned in this document in this method.
- * @param parent The parent for any display objects encoded in the array.
- * @param data The encoded data.
- * @return The Array.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function generateMXMLArray(document:Object, parent:IParent, data:Array):Array
- {
- var comps:Array = [];
-
- var n:int = data.length;
- var i:int = 0;
- while (i < n)
- {
- var cls:Class = data[i++];
- var comp:Object = new cls();
-
- i = initializeStrandBasedObject(document, parent, comp, data, i);
-
- comps.push(comp);
- }
- return comps;
- }
-
- /**
- * @flexjsignorecoercion Function
- */
- private static function initializeStrandBasedObject(document:Object, parent:IParent, comp:Object, data:Array, i:int):int
- {
- var m:int;
- var j:int;
- var name:String;
- var simple:*;
- var value:Object;
- var id:String = null;
-
- m = data[i++]; // num props
- if (m > 0 && data[0] == "model")
- {
- m--;
- name = data[i++];
- simple = data[i++];
- value = data[i++];
- if (simple == null)
- value = generateMXMLArray(document, parent, value as Array);
- else if (simple == false)
- value = generateMXMLObject(document, value as Array);
- comp[name] = value;
- if (value is IBead && comp is IStrand)
- IStrand(comp).addBead(value as IBead);
- }
- var beadOffset:int = i + (m - 1) * 3;
- //if (beadOffset >= -1)
- // trace(beadOffset, data[beadOffset]);
- if (m > 0 && data[beadOffset] == "beads")
- {
- m--;
- }
- else
- beadOffset = -1;
- for (j = 0; j < m; j++)
- {
- name = data[i++];
- simple = data[i++];
- value = data[i++];
- if (simple == null)
- value = generateMXMLArray(document, null, value as Array);
- else if (simple == false)
- value = generateMXMLObject(document, value as Array);
- if (name == "id")
- id = value as String;
- if (name == "document" && !comp.document)
- comp.document = document;
- else if (name == "_id")
- id = value as String; // and don't assign to comp
- else if (name == "id")
- {
- // not all objects have to have their own id property
- try {
- comp["id"] = value;
- } catch (e:Error)
- {
-
- }
- }
- else
- comp[name] = value;
- }
- if (beadOffset > -1)
- {
- name = data[i++];
- simple = data[i++];
- value = data[i++];
- if (simple == null)
- value = generateMXMLArray(document, null, value as Array);
- else if (simple == false)
- value = generateMXMLObject(document, value as Array);
- comp[name] = value;
- }
- m = data[i++]; // num styles
- for (j = 0; j < m; j++)
- {
- name = data[i++];
- simple = data[i++];
- value = data[i++];
- if (simple == null)
- value = generateMXMLArray(document, null, value as Array);
- else if (simple == false)
- value = generateMXMLObject(document, value as Array);
- comp.setStyle(name, value);
- }
-
- COMPILE::AS3
- {
- // flexjs on the JS side won't have effects in here, they are regular properties
- // but falcon provides this set for SWFs for future compatibility with
- // the older flex-sdk.
- m = data[i++]; // num effects
- for (j = 0; j < m; j++)
- {
- name = data[i++];
- simple = data[i++];
- value = data[i++];
- if (simple == null)
- value = generateMXMLArray(document, null, value as Array);
- else if (simple == false)
- value = generateMXMLObject(document, value as Array);
- comp.setStyle(name, value);
- }
- }
-
- m = data[i++]; // num events
- for (j = 0; j < m; j++)
- {
- name = data[i++];
- value = data[i++];
- COMPILE::AS3
- {
- comp.addEventListener(name, value);
- }
- COMPILE::JS
- {
- comp.addEventListener(name, goog.bind(value as Function, document));
- }
- }
-
- var children:Array = data[i++];
- if (children && comp is IMXMLDocument)
- {
- comp.setMXMLDescriptor(document, children);
- }
- COMPILE::AS3
- {
- if (parent && comp is DisplayObject)
- parent.addElement(comp, !(parent is IContainer));
- }
- COMPILE::JS
- {
- if (parent && comp is IUIBase)
- parent.addElement(comp, !(parent is IContainer));
- }
-
- if (children)
- {
- if (!(comp is IMXMLDocument))
- {
- generateMXMLInstances(document, comp as IParent, children);
- }
- }
-
- if (id)
- document[id] = comp;
-
- if (comp is IDocument)
- comp.setDocument(document, id);
-
- return i;
- }
-
- /**
- * Generates the instances of objects in an MXML document based on the encoded data.
- *
- * @param document The MXML document. If the object has an id
- * it will be assigned in this document in this method.
- * @param parent The parent for any display objects encoded in the array.
- * @param data The encoded data.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function generateMXMLInstances(document:Object, parent:IParent, data:Array):void
- {
- if (!data) return;
-
- generateMXMLArray(document, parent, data);
- // maybe we can remove this. All IContainers should be IMXMLDocuments?
- if (parent is IContainer)
- {
- IContainer(parent).childrenAdded();
- }
- }
-
- /**
- * Generates the properties of the top-level object in an MXML document
- * based on the encoded data. This basically means setting the attributes
- * found on the tag and child tags that aren't in the default property.
- *
- * @param host The MXML document. If the object has an id
- * it will be assigned in this document in this method.
- * @param data The encoded data.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- * @flexjsignorecoercion Function
- */
- public static function generateMXMLProperties(host:Object, data:Array):void
- {
- if (!data) return;
-
- var i:int = 0;
- var m:int;
- var j:int;
- var name:String;
- var simple:*;
- var value:Object;
- var id:String = null;
-
- m = data[i++]; // num props
- var beadOffset:int = i + (m - 1) * 3;
- //if (beadOffset >= -1)
- // (beadOffset, data[beadOffset]);
- if (m > 0 && data[beadOffset] == "beads")
- {
- m--;
- }
- else
- beadOffset = -1;
- for (j = 0; j < m; j++)
- {
- name = data[i++];
- simple = data[i++];
- value = data[i++];
- if (simple == null)
- value = generateMXMLArray(host, null, value as Array);
- else if (simple == false)
- value = generateMXMLObject(host, value as Array);
- if (name == "id")
- id = value as String;
- if (name == "_id")
- id = value as String; // and don't assign
- else
- host[name] = value;
- }
- if (beadOffset > -1)
- {
- name = data[i++];
- simple = data[i++];
- value = data[i++];
- if (simple == null)
- value = generateMXMLArray(host, null, value as Array);
- else if (simple == false)
- value = generateMXMLObject(host, value as Array);
- host[name] = value;
- }
- m = data[i++]; // num styles
- for (j = 0; j < m; j++)
- {
- name = data[i++];
- simple = data[i++];
- value = data[i++];
- if (simple == null)
- value = generateMXMLArray(host, null, value as Array);
- else if (simple == false)
- value = generateMXMLObject(host, value as Array);
- host[name] = value;
- }
-
- COMPILE::AS3
- {
- // flexjs on the JS side won't have effects in here, they are regular properties
- // but falcon provides this set for SWFs for future compatibility with
- // the older flex-sdk.
- m = data[i++]; // num effects
- for (j = 0; j < m; j++)
- {
- name = data[i++];
- simple = data[i++];
- value = data[i++];
- if (simple == null)
- value = generateMXMLArray(host, null, value as Array);
- else if (simple == false)
- value = generateMXMLObject(host, value as Array);
- host[name] = value;
- }
- }
-
- m = data[i++]; // num events
- for (j = 0; j < m; j++)
- {
- name = data[i++];
- value = data[i++];
- COMPILE::AS3
- {
- host.addEventListener(name, value as Function);
- }
- COMPILE::JS
- {
- host.addEventListener(name, goog.bind(value as Function, host));
- }
- }
-
- }
-
-}
-}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a903508e/frameworks/projects/Core/as/src/org/apache/flex/utils/MixinManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/MixinManager.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/MixinManager.as
deleted file mode 100644
index ab5dfed..0000000
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/MixinManager.as
+++ /dev/null
@@ -1,105 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.utils
-{
-
-COMPILE::AS3
-{
- import flash.system.ApplicationDomain;
-}
-
-import org.apache.flex.core.IBead;
-import org.apache.flex.core.IFlexInfo;
-import org.apache.flex.core.IStrand;
-
-/**
- * The MixinManager class is the class that instantiates mixins
- * linked into the application. Mixins are classes with [Mixin]
- * metadata and are often linked in via the -includes option.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
-public class MixinManager implements IBead
-{
- /**
- * Constructor.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public function MixinManager()
- {
- super();
- }
-
- private var _strand:IStrand;
-
- /**
- * @copy org.apache.flex.core.IBead#strand
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- * @flexjsignorecoercion Array
- * @flexjsignorecoercion org.apache.flex.core.IFlexInfo
- * @flexjsignoreimport org.apache.flex.core.IFlexInfo
- */
- public function set strand(value:IStrand):void
- {
- _strand = value;
-
- COMPILE::AS3
- {
- var app:IFlexInfo = value as IFlexInfo;
- if (app)
- {
- var mixins:Array = app.info().mixins;
- var domain:ApplicationDomain = app.info().currentDomain;
- for each (var mixin:String in mixins)
- {
- var mixinClass:Object = domain.getDefinition(mixin);
- mixinClass.init(value);
- }
- }
- }
- COMPILE::JS
- {
- var app:IFlexInfo = value as IFlexInfo;
- if (app)
- {
- var mixins:Array = app.info()['mixins'] as Array;
- if (mixins) {
- var n:int = mixins.length;
- for (var i:int = 0; i < n; i++)
- {
- mixins[i].init(value);
- }
- }
- }
- }
- }
-
-}
-}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a903508e/frameworks/projects/Core/as/src/org/apache/flex/utils/PNGEncoder.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/PNGEncoder.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/PNGEncoder.as
deleted file mode 100644
index d34ce13..0000000
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/PNGEncoder.as
+++ /dev/null
@@ -1,305 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package org.apache.flex.utils
-{
-
-import flash.display.BitmapData;
-import flash.utils.ByteArray;
-
-/**
- * The PNGEncoder class converts raw bitmap images into encoded
- * images using Portable Network Graphics (PNG) lossless compression.
- *
- * <p>For the PNG specification, see http://www.w3.org/TR/PNG/</p>.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
-COMPILE::AS3
-public class PNGEncoder
-{
-
- // this is a copy of mx.graphics.codec.PNGEncoder
-
- //--------------------------------------------------------------------------
- //
- // Class constants
- //
- //--------------------------------------------------------------------------
-
- /**
- * @private
- * The MIME type for a PNG image.
- */
- private static const CONTENT_TYPE:String = "image/png";
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructor.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function PNGEncoder()
- {
- super();
-
- initializeCRCTable();
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * @private
- * Used for computing the cyclic redundancy checksum
- * at the end of each chunk.
- */
- private var crcTable:Array;
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // contentType
- //----------------------------------
-
- /**
- * The MIME type for the PNG encoded image.
- * The value is <code>"image/png"</code>.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get contentType():String
- {
- return CONTENT_TYPE;
- }
-
- //--------------------------------------------------------------------------
- //
- // Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Converts the pixels of a BitmapData object
- * to a PNG-encoded ByteArray object.
- *
- * @param bitmapData The input BitmapData object.
- *
- * @return Returns a ByteArray object containing PNG-encoded image data.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function encode(bitmapData:BitmapData):ByteArray
- {
- return internalEncode(bitmapData, bitmapData.width, bitmapData.height,
- bitmapData.transparent);
- }
-
- /**
- * Converts a ByteArray object containing raw pixels
- * in 32-bit ARGB (Alpha, Red, Green, Blue) format
- * to a new PNG-encoded ByteArray object.
- * The original ByteArray is left unchanged.
- *
- * @param byteArray The input ByteArray object containing raw pixels.
- * This ByteArray should contain
- * <code>4 * width * height</code> bytes.
- * Each pixel is represented by 4 bytes, in the order ARGB.
- * The first four bytes represent the top-left pixel of the image.
- * The next four bytes represent the pixel to its right, etc.
- * Each row follows the previous one without any padding.
- *
- * @param width The width of the input image, in pixels.
- *
- * @param height The height of the input image, in pixels.
- *
- * @param transparent If <code>false</code>, alpha channel information
- * is ignored but you still must represent each pixel
- * as four bytes in ARGB format.
- *
- * @return Returns a ByteArray object containing PNG-encoded image data.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function encodeByteArray(byteArray:ByteArray, width:int, height:int,
- transparent:Boolean = true):ByteArray
- {
- return internalEncode(byteArray, width, height, transparent);
- }
-
- /**
- * @private
- */
- private function initializeCRCTable():void
- {
- crcTable = [];
-
- for (var n:uint = 0; n < 256; n++)
- {
- var c:uint = n;
- for (var k:uint = 0; k < 8; k++)
- {
- if (c & 1)
- c = uint(uint(0xedb88320) ^ uint(c >>> 1));
- else
- c = uint(c >>> 1);
- }
- crcTable[n] = c;
- }
- }
-
- /**
- * @private
- */
- private function internalEncode(source:Object, width:int, height:int,
- transparent:Boolean = true):ByteArray
- {
- // The source is either a BitmapData or a ByteArray.
- var sourceBitmapData:BitmapData = source as BitmapData;
- var sourceByteArray:ByteArray = source as ByteArray;
-
- if (sourceByteArray)
- sourceByteArray.position = 0;
-
- // Create output byte array
- var png:ByteArray = new ByteArray();
-
- // Write PNG signature
- png.writeUnsignedInt(0x89504E47);
- png.writeUnsignedInt(0x0D0A1A0A);
-
- // Build IHDR chunk
- var IHDR:ByteArray = new ByteArray();
- IHDR.writeInt(width);
- IHDR.writeInt(height);
- IHDR.writeByte(8); // bit depth per channel
- IHDR.writeByte(6); // color type: RGBA
- IHDR.writeByte(0); // compression method
- IHDR.writeByte(0); // filter method
- IHDR.writeByte(0); // interlace method
- writeChunk(png, 0x49484452, IHDR);
-
- // Build IDAT chunk
- var IDAT:ByteArray = new ByteArray();
- for (var y:int = 0; y < height; y++)
- {
- IDAT.writeByte(0); // no filter
-
- var x:int;
- var pixel:uint;
-
- if (!transparent)
- {
- for (x = 0; x < width; x++)
- {
- if (sourceBitmapData)
- pixel = sourceBitmapData.getPixel(x, y);
- else
- pixel = sourceByteArray.readUnsignedInt();
-
- IDAT.writeUnsignedInt(uint(((pixel & 0xFFFFFF) << 8) | 0xFF));
- }
- }
- else
- {
- for (x = 0; x < width; x++)
- {
- if (sourceBitmapData)
- pixel = sourceBitmapData.getPixel32(x, y);
- else
- pixel = sourceByteArray.readUnsignedInt();
-
- IDAT.writeUnsignedInt(uint(((pixel & 0xFFFFFF) << 8) |
- (pixel >>> 24)));
- }
- }
- }
- IDAT.compress();
- writeChunk(png, 0x49444154, IDAT);
-
- // Build IEND chunk
- writeChunk(png, 0x49454E44, null);
-
- // return PNG
- png.position = 0;
- return png;
- }
-
- /**
- * @private
- */
- private function writeChunk(png:ByteArray, type:uint, data:ByteArray):void
- {
- // Write length of data.
- var len:uint = 0;
- if (data)
- len = data.length;
- png.writeUnsignedInt(len);
-
- // Write chunk type.
- var typePos:uint = png.position;
- png.writeUnsignedInt(type);
-
- // Write data.
- if (data)
- png.writeBytes(data);
-
- // Write CRC of chunk type and data.
- var crcPos:uint = png.position;
- png.position = typePos;
- var crc:uint = 0xFFFFFFFF;
- for (var i:uint = typePos; i < crcPos; i++)
- {
- crc = uint(crcTable[(crc ^ png.readUnsignedByte()) & uint(0xFF)] ^
- uint(crc >>> 8));
- }
- crc = uint(crc ^ uint(0xFFFFFFFF));
- png.position = crcPos;
- png.writeUnsignedInt(crc);
- }
-}
-
-}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a903508e/frameworks/projects/Core/as/src/org/apache/flex/utils/PointUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/PointUtils.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/PointUtils.as
deleted file mode 100644
index 09c88b4..0000000
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/PointUtils.as
+++ /dev/null
@@ -1,125 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.utils
-{
- COMPILE::AS3
- {
- import flash.display.DisplayObject;
- import flash.geom.Point;
- }
-
- import org.apache.flex.core.IUIBase;
- import org.apache.flex.geom.Point;
-
- /**
- * The PointUtils class is a collection of static functions that convert
- * Points between coordinate spaces.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public class PointUtils
- {
- /**
- * @private
- */
- public function PointUtils()
- {
- throw new Error("PointUtils should not be instantiated.");
- }
-
- /**
- * Converts a point from global coordinates to local coordinates
- *
- * @param point The point being converted.
- * @param local The component used as reference for the conversion.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- * @flexjsignorecoercion HTMLElement
- */
- public static function globalToLocal( pt:org.apache.flex.geom.Point, local:Object ):org.apache.flex.geom.Point
- {
- COMPILE::AS3
- {
- var fpt:flash.geom.Point = DisplayObject(local).globalToLocal(pt);
- return new org.apache.flex.geom.Point(fpt.x, fpt.y);
- }
- COMPILE::JS
- {
- var x:Number = pt.x;
- var y:Number = pt.y;
- var element:HTMLElement = local.element as HTMLElement;
-
- do {
- x -= element.offsetLeft;
- y -= element.offsetTop;
- if (local.hasOwnProperty('parent')) {
- local = local.parent;
- element = local.element as HTMLElement;
- } else {
- element = null;
- }
- }
- while (element);
- return new org.apache.flex.geom.Point(x, y);
-
- }
- }
-
- /**
- * Converts a point from local coordinates to global coordinates
- *
- * @param point The point being converted.
- * @param local The component used as reference for the conversion.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- * @flexjsignorecoercion HTMLElement
- */
- public static function localToGlobal( pt:org.apache.flex.geom.Point, local:Object ):org.apache.flex.geom.Point
- {
- COMPILE::AS3
- {
- var fpt:flash.geom.Point = DisplayObject(local).localToGlobal(pt);
- return new org.apache.flex.geom.Point(fpt.x, fpt.y);
- }
- COMPILE::JS
- {
- var x:Number = pt.x;
- var y:Number = pt.y;
- var element:HTMLElement = local.element as HTMLElement;
-
- do {
- x += element.offsetLeft;
- y += element.offsetTop;
- element = element.offsetParent as HTMLElement;
- }
- while (element);
- return new org.apache.flex.geom.Point(x, y);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a903508e/frameworks/projects/Core/as/src/org/apache/flex/utils/SolidBorderUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/SolidBorderUtil.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/SolidBorderUtil.as
deleted file mode 100644
index bb74b2a..0000000
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/SolidBorderUtil.as
+++ /dev/null
@@ -1,191 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.utils
-{
-import flash.display.Graphics;
-
-
-/**
- * The SolidBorderUtil class is a utility class that draws a solid color
- * border of a specified color, thickness and alpha. This class is used
- * to composite Flash equivalents of JS entities and has no JS
- * equivalent.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
-COMPILE::AS3
-public class SolidBorderUtil
-{
- /**
- * Draw a solid color border as specified. Will fill with
- * the backgroundColor if specified. The border draws
- * inside with given width/height.
- *
- * @param g The flash.display.DisplayObject#graphics
- * @param x The x position
- * @param y The y position
- * @param width The width
- * @param height The height
- * @param color The color
- * @param backgroundColor The optional fill color
- * @param thickness The thickness of the border
- * @param alpha The alpha
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function drawBorder(g:Graphics, x:Number, y:Number,
- width:Number, height:Number,
- color:uint, backgroundColor:Object = null,
- thickness:int = 1, alpha:Number = 1.0,
- ellipseWidth:Number = NaN, ellipseHeight:Number = NaN):void
- {
- g.lineStyle(); // don't draw the line, it tends to get aligned on half-pixels
-
- if (thickness > 0)
- {
- g.beginFill(color, alpha);
- if (!isNaN(ellipseWidth))
- {
- g.drawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight);
- g.drawRoundRect(x + thickness, y + thickness,
- width - thickness * 2, height - thickness * 2,
- ellipseWidth, ellipseHeight);
- }
- else
- {
- g.drawRect(x, y, width, height);
- g.drawRect(x + thickness, y + thickness,
- width - thickness * 2, height - thickness * 2);
- }
- g.endFill();
- }
-
- if (backgroundColor != null)
- {
- g.beginFill(uint(backgroundColor), alpha);
-
- if (!isNaN(ellipseWidth))
- g.drawRoundRect(x + thickness, y + thickness,
- width - thickness * 2, height - thickness * 2,
- ellipseWidth, ellipseHeight);
- else
- g.drawRect(x + thickness, y + thickness,
- width - thickness * 2, height - thickness * 2);
- g.endFill();
- }
- }
-
- /**
- * Draw a solid color border as specified. Only square corners
- * are supported as the real usage for this is to handle
- * CSS triangles. The border is drawn around the given
- * width and height.
- *
- * @param g The flash.display.DisplayObject#graphics
- * @param x The x position
- * @param y The y position
- * @param width The width
- * @param height The height
- * @param colorTop The rgba color (alpha is in highest order byte)
- * @param colorRight The rgba color
- * @param colorBottom The rgba color
- * @param colorLeft The rgba color
- * @param backgroundColor The optional fill color
- * @param thicknessTop The thickness of the border
- * @param thicknessRight The thickness of the border
- * @param thicknessBottom The thickness of the border
- * @param thicknessLeft The thickness of the border
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function drawDetailedBorder(g:Graphics, x:Number, y:Number,
- width:Number, height:Number,
- colorTop:uint, colorRight:uint, colorBottom:uint, colorLeft:uint,
- thicknessTop:int = 0, thicknessRight:int = 0, thicknessBottom:int = 0, thicknessLeft:int = 0
- ):void
- {
- g.lineStyle(); // don't draw the line, it tends to get aligned on half-pixels
-
- var color:uint;
- var alpha:Number;
- if (thicknessTop > 0)
- {
- color = colorTop & 0xFFFFFF;
- alpha = (colorTop >>> 24 & 0xFF) / 255;
- g.beginFill(color, alpha);
- g.moveTo(0, 0);
- g.lineTo(width + thicknessRight + thicknessLeft, 0);
- if (width > 0)
- g.lineTo(width + thicknessLeft, thicknessTop);
- g.lineTo(thicknessLeft, thicknessTop);
- g.lineTo(0, 0);
- g.endFill();
- }
- if (thicknessLeft > 0)
- {
- color = colorLeft & 0xFFFFFF;
- alpha = (colorLeft >>> 24 & 0xFF) / 255;
- g.beginFill(color, alpha);
- g.moveTo(0, 0);
- g.lineTo(thicknessLeft, thicknessTop);
- if (height > 0)
- g.lineTo(thicknessLeft, thicknessTop + height);
- g.lineTo(0, height + thicknessBottom);
- g.lineTo(0, 0);
- g.endFill();
- }
- if (thicknessRight > 0)
- {
- color = colorRight & 0xFFFFFF;
- alpha = (colorRight >>> 24 & 0xFF) / 255;
- g.beginFill(color, alpha);
- g.moveTo(width + thicknessRight + thicknessLeft, 0);
- g.lineTo(width + thicknessRight + thicknessLeft, height + thicknessBottom + thicknessTop);
- if (height > 0)
- g.lineTo(width + thicknessLeft, height + thicknessTop);
- g.lineTo(width + thicknessLeft, thicknessTop);
- g.lineTo(width + thicknessRight + thicknessLeft, 0);
- g.endFill();
- }
- if (thicknessBottom > 0)
- {
- color = colorBottom & 0xFFFFFF;
- alpha = (colorBottom >>> 24 & 0xFF) / 255;
- g.beginFill(color, alpha);
- g.moveTo(0, height + thicknessBottom + thicknessTop);
- g.lineTo(thicknessLeft, height + thicknessTop);
- if (width > 0)
- g.lineTo(width + thicknessLeft, height + thicknessTop);
- g.lineTo(width + thicknessRight + thicknessLeft, height + thicknessBottom + thicknessTop);
- g.lineTo(0, height + thicknessBottom + thicknessTop);
- g.endFill();
- }
- }
-
-}
-}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a903508e/frameworks/projects/Core/as/src/org/apache/flex/utils/StringTrimmer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/StringTrimmer.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/StringTrimmer.as
deleted file mode 100644
index fe170df..0000000
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/StringTrimmer.as
+++ /dev/null
@@ -1,176 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.utils
-{
-
- /**
- * The StringTrimmer class is a collection of static functions that provide utility
- * features for trimming whitespace off Strings.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- COMPILE::AS3
- public class StringTrimmer
- {
- /**
- * @private
- */
- public function StringTrimmer()
- {
- throw new Error("StringTrimmer should not be instantiated.");
- }
-
- /**
- * Removes all whitespace characters from the beginning and end
- * of the specified string.
- *
- * @param str The String whose whitespace should be trimmed.
- *
- * @return Updated String where whitespace was removed from the
- * beginning and end.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function trim(str:String):String
- {
- if (str == null) return '';
-
- var startIndex:int = 0;
- while (isWhitespace(str.charAt(startIndex)))
- ++startIndex;
-
- var endIndex:int = str.length - 1;
- while (isWhitespace(str.charAt(endIndex)))
- --endIndex;
-
- if (endIndex >= startIndex)
- return str.slice(startIndex, endIndex + 1);
- else
- return "";
- }
-
- /**
- * Removes all whitespace characters from the beginning and end
- * of each element in an Array, where the Array is stored as a String.
- *
- * @param value The String whose whitespace should be trimmed.
- *
- * @param separator The String that delimits each Array element in the string.
- *
- * @return Array where whitespace was removed from the
- * beginning and end of each element.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function splitAndTrim(value:String, delimiter:String):Array
- {
- if (value != "" && value != null)
- {
- var items:Array = value.split(delimiter);
-
- var len:int = items.length;
- for (var i:int = 0; i < len; i++)
- {
- items[i] = StringTrimmer.trim(items[i]);
- }
- return items;
- }
-
- return [];
- }
-
- /**
- * Removes all whitespace characters from the beginning and end
- * of each element in an Array, where the Array is stored as a String.
- *
- * @param value The String whose whitespace should be trimmed.
- *
- * @param separator The String that delimits each Array element in the string.
- *
- * @return Updated String where whitespace was removed from the
- * beginning and end of each element.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function trimArrayElements(value:String, delimiter:String):String
- {
- if (value != "" && value != null)
- {
- var items:Array = splitAndTrim(value, delimiter);
- if (items.length > 0)
- {
- value = items.join(delimiter);
- }
- }
-
- return value;
- }
-
- /**
- * Returns <code>true</code> if the specified string is
- * a single space, tab, carriage return, newline, or formfeed character.
- *
- * @param str The String that is is being queried.
- *
- * @return <code>true</code> if the specified string is
- * a single space, tab, carriage return, newline, or formfeed character.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public static function isWhitespace(character:String):Boolean
- {
- switch (character)
- {
- case " ":
- case "\t":
- case "\r":
- case "\n":
- case "\f":
- // non breaking space
- case "\u00A0":
- // line seperator
- case "\u2028":
- // paragraph seperator
- case "\u2029":
- // ideographic space
- case "\u3000":
- return true;
-
- default:
- return false;
- }
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a903508e/frameworks/projects/Core/as/src/org/apache/flex/utils/Timer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/Timer.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/Timer.as
deleted file mode 100644
index 582d884..0000000
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/Timer.as
+++ /dev/null
@@ -1,148 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.utils
-{
-COMPILE::AS3
-{
- import flash.events.TimerEvent;
- import flash.utils.Timer;
-}
-
-import org.apache.flex.events.Event;
-
-COMPILE::JS
-{
- import org.apache.flex.events.EventDispatcher;
-}
-
-//--------------------------------------
-// Events
-//--------------------------------------
-
-/**
- * Dispatched as requested via the delay and
- * repeat count parameters in the constructor.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
-[Event(name="timer", type="org.apache.flex.events.Event")]
-
-/**
- * The Timer class dispatches events based on a delay
- * and repeat count.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
-COMPILE::AS3
-public class Timer extends flash.utils.Timer
-{
- /**
- * Constructor.
- *
- * @param delay The number of milliseconds
- * to wait before dispatching the event.
- * @param repeatCount The number of times to dispatch
- * the event. If 0, keep dispatching forever.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public function Timer(delay:Number, repeatCount:int = 0)
- {
- super(delay, repeatCount);
- addEventListener("timer", interceptor, false, 9999);
- }
-
- private function interceptor(event:flash.events.Event):void
- {
- if (event is TimerEvent)
- {
- event.stopImmediatePropagation();
- dispatchEvent(new Event("timer"));
- }
- }
-}
-
-COMPILE::JS
-public class Timer extends EventDispatcher
-{
- /**
- * Constructor.
- *
- * @param delay The number of milliseconds
- * to wait before dispatching the event.
- * @param repeatCount The number of times to dispatch
- * the event. If 0, keep dispatching forever.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public function Timer(delay:Number, repeatCount:int = 0)
- {
- this.delay = delay;
- this.repeatCount = repeatCount;
- }
-
- public var delay:Number;
- public var repeatCount:int;
-
- private var currentCount:int = 0;
-
- private var timerInterval:int = -1;
-
- public function reset():void
- {
- stop();
- currentCount = 0;
- }
-
- public function stop():void
- {
- clearInterval(timerInterval);
- timerInterval = -1;
- }
-
- public function start():void
- {
- timerInterval =
- setInterval(timerHandler, delay);
- }
-
- private function timerHandler():void
- {
- currentCount++;
- if (repeatCount > 0 && currentCount >= repeatCount) {
- stop();
- }
-
- dispatchEvent(new Event('timer'));
- }
-}
-
-}