public virtual void testArrayCreation()
 {
     AsArray oneArray = new AsArray();
     AsArray twoArray = new AsArray("a", "b", "c");
     AsArray threeArray = new AsArray("a", "b", "c");
     AsArray fourArray = (new AsArray("a", "b", "c"));
 }
예제 #2
0
 public virtual void testArrayCreation()
 {
     AsArray oneArray   = new AsArray();
     AsArray twoArray   = new AsArray("a", "b", "c");
     AsArray threeArray = new AsArray("a", "b", "c");
     AsArray fourArray  = (new AsArray("a", "b", "c"));
 }
예제 #3
0
        public virtual void testArrayIndexer()
        {
            AsArray oneArray = new AsArray();

            oneArray[0] = "a";
            String val = (String)(oneArray[0]);
        }
        public virtual void testMethods()
        {
            String str          = "This is a string";
            String chrString    = AsString.charAt(str, 0);
            float  chrCode      = AsString.charCodeAt(str, 0);
            String fromCharCode = AsString.fromCharCode(0);
            int    indexOf      = AsString.indexOf(str, "string");

            indexOf = AsString.indexOf(str, "string", 0);
            String replace = AsString.replace(str, "string", "foo");
            String slice   = AsString.slice(str, 0);

            slice = AsString.slice(str, 0, 10);
            AsArray split  = AsString.split(str, " ");
            String  substr = AsString.substr(str, 0);

            substr = AsString.substring(str, 0, 10);
            String substring = AsString.substring(str, 0);

            substring = AsString.substring(str, 0, 10);
            String toLocalLowerCase = AsString.toLocaleLowerCase(str);
            String toLocalUpperCase = AsString.toLocaleUpperCase(str);
            String toLowerCase      = AsString.toLowerCase(str);
            String toUpperCase      = AsString.toUpperCase(str);
            String toString         = str.ToString();
            String valueOf          = AsString.valueOf(str);
        }
예제 #5
0
        public virtual int CompareTo(BsonValue other)
        {
            // first, test if types are diferentes
            if (Type != other.Type)
            {
                // if both values are number, convert them to Double to compare
                if (IsNumber && other.IsNumber)
                {
                    return(Convert.ToDouble(RawValue).CompareTo(Convert.ToDouble(RawValue)));
                }
                // if not, order by sort type order
                return(Type.CompareTo(other.Type));
            }

            // for both values with same datatype just compare
            switch (Type)
            {
            case BsonType.Null:
            case BsonType.MinValue:
            case BsonType.MaxValue:
                return(0);

            case BsonType.Int32:
                return(((int)RawValue).CompareTo((int)other.RawValue));

            case BsonType.Int64:
                return(((long)RawValue).CompareTo((long)other.RawValue));

            case BsonType.Double:
                return(((double)RawValue).CompareTo((double)other.RawValue));

            case BsonType.String:
                return(string.Compare((string)RawValue, (string)other.RawValue));

            case BsonType.Document:
                return(AsDocument.CompareTo(other));

            case BsonType.Array:
                return(AsArray.CompareTo(other));

            case BsonType.Binary:
                return(((byte[])RawValue).BinaryCompareTo((byte[])other.RawValue));

            case BsonType.ObjectId:
                return(((ObjectId)RawValue).CompareTo((ObjectId)other.RawValue));

            case BsonType.Guid:
                return(((Guid)RawValue).CompareTo((Guid)other.RawValue));

            case BsonType.Boolean:
                return(((bool)RawValue).CompareTo((bool)other.RawValue));

            case BsonType.DateTime:
                return(((DateTime)RawValue).CompareTo((DateTime)other.RawValue));

            default:
                throw new NotImplementedException();
            }
        }
 public virtual void testArrayPush()
 {
     AsArray oneArray = new AsArray();
     oneArray.push();
     oneArray.push("a");
     oneArray.push("a", "b", "c");
     oneArray.push(new AsArray("a", "b", "c"));
 }
예제 #7
0
        public virtual void testArrayPush()
        {
            AsArray oneArray = new AsArray();

            oneArray.push();
            oneArray.push("a");
            oneArray.push("a", "b", "c");
            oneArray.push(new AsArray("a", "b", "c"));
        }
 public virtual AsDelayedCall reset(AsDelayedCallback call, float delay, AsArray args)
 {
     mCurrentTime = 0;
     mTotalTime   = AsMath.max(delay, 0.0001f);
     mCall        = call;
     mArgs        = args;
     mRepeatCount = 1;
     return(this);
 }
 public virtual AsDelayedCall reset(AsDelayedCallback call, float delay, AsArray args)
 {
     mCurrentTime = 0;
     mTotalTime = AsMath.max(delay, 0.0001f);
     mCall = call;
     mArgs = args;
     mRepeatCount = 1;
     return this;
 }
예제 #10
0
 public virtual void setNativeFilters(AsArray _value)
 {
     if (!mIsRenderedText)
     {
         throw new AsError("The TextField.nativeFilters property cannot be used on Bitmap fonts.");
     }
     mNativeFilters  = _value.concat();
     mRequiresRedraw = true;
 }
예제 #11
0
 public virtual AsTween reset(Object target, float time, Object transition)
 {
     mTarget       = target;
     mCurrentTime  = 0;
     mTotalTime    = AsMath.max(0.0001f, time);
     mDelay        = mRepeatDelay = 0.0f;
     mOnStart      = mOnUpdate = mOnComplete = null;
     mOnStartArgs  = mOnUpdateArgs = mOnCompleteArgs = null;
     mRoundToInt   = mReverse = false;
     mRepeatCount  = 1;
     mCurrentCycle = -1;
     if (transition is String)
     {
         this.setTransition(transition as String);
     }
     else
     {
         if (transition is AsTransitionCallback)
         {
             this.setTransitionFunc(transition as AsTransitionCallback);
         }
         else
         {
             throw new AsArgumentError("Transition must be either a string or a function");
         }
     }
     if (mProperties != null)
     {
         mProperties.setLength(0);
     }
     else
     {
         mProperties = new AsVector <String>();
     }
     if (mStartValues != null)
     {
         mStartValues.setLength(0);
     }
     else
     {
         mStartValues = new AsVector <float>();
     }
     if (mEndValues != null)
     {
         mEndValues.setLength(0);
     }
     else
     {
         mEndValues = new AsVector <float>();
     }
     return(this);
 }
예제 #12
0
        public virtual void dispose()
        {
            stop();
            mNativeStage.removeEventListener(AsEvent.ENTER_FRAME, onEnterFrame, false);
            mNativeStage.removeEventListener(AsKeyboardEvent.KEY_DOWN, onKey, false);
            mNativeStage.removeEventListener(AsKeyboardEvent.KEY_UP, onKey, false);
            mNativeStage.removeEventListener(AsEvent.RESIZE, onResize, false);
            mNativeStage.removeChild(mNativeOverlay);
            mStage3D.removeEventListener(AsEvent.CONTEXT3D_CREATE, onContextCreated, false);
            mStage3D.removeEventListener(AsErrorEvent.ERROR, onStage3DError, false);
            AsArray __touchEventTypes_ = getTouchEventTypes();

            if (__touchEventTypes_ != null)
            {
                foreach (String touchEventType in __touchEventTypes_)
                {
                    mNativeStage.removeEventListener(touchEventType, onTouch, false);
                }
            }
            AsDictionary __programs_ = mPrograms;

            if (__programs_ != null)
            {
                foreach (AsProgram3D program in __programs_)
                {
                    program.dispose();
                }
            }
            if (mStage != null)
            {
                mStage.dispose();
            }
            if (mSupport != null)
            {
                mSupport.dispose();
            }
            if (mTouchProcessor != null)
            {
                mTouchProcessor.dispose();
            }
            if (mContext != null && !mShareContext)
            {
                mContext.dispose();
            }
            if (sCurrent == this)
            {
                sCurrent = null;
            }
        }
예제 #13
0
        public string _GetDescription(int depth)
        {
            if (depth > 10)
            {
                throw new Exception("LPCValue层次太深(depth=" + depth + ")! 可能是出现自引用!");
            }

            string blank = LPCUtil.GetSpace(4 * depth);

            if (IsUndefined)
            {
                return(string.Format("{0}(undefined)", blank));
            }
            else if (IsInt)
            {
                return(string.Format("{0}{1}", blank, AsInt));
            }
            else if (IsFloat)
            {
                return(string.Format("{0}{1}", blank, AsFloat));
            }
            else if (IsString)
            {
                return(string.Format("{0}\"{1}\"", blank, AsString));
            }
            else if (IsBuffer)
            {
                return(string.Format("{0}<buffer:{1}>", blank, AsBuffer.Length));
            }
            else if (IsArray)
            {
                return(AsArray._GetDescription(depth));
            }
            else if (IsMapping)
            {
                return(AsMapping._GetDescription(depth));
            }

            Debug.Assert(false, "按理说不应该走到这里");
            return("");
        }
예제 #14
0
        public virtual int CompareTo(BsonValue other)
        {
            // first, test if types are different
            if (Type != other.Type)
            {
                // if both values are number, convert them to Decimal (128 bits) to compare
                // it's the slowest way, but more secure
                if (IsNumber && other.IsNumber)
                {
                    return(Convert.ToDecimal(RawValue).CompareTo(Convert.ToDecimal(other.RawValue)));
                }
                // if not, order by sort type order
                else
                {
                    return(Type.CompareTo(other.Type));
                }
            }

            // for both values with same data type just compare
            switch (Type)
            {
            case BsonType.Null:
            case BsonType.MinValue:
            case BsonType.MaxValue:
                return(0);

            case BsonType.Int32: return(((Int32)RawValue).CompareTo((Int32)other.RawValue));

            case BsonType.Int64: return(((Int64)RawValue).CompareTo((Int64)other.RawValue));

            case BsonType.Double: return(((Double)RawValue).CompareTo((Double)other.RawValue));

            case BsonType.Decimal: return(((Decimal)RawValue).CompareTo((Decimal)other.RawValue));

            case BsonType.String: return(string.Compare((String)RawValue, (String)other.RawValue));

            case BsonType.Document: return(AsDocument.CompareTo(other));

            case BsonType.Array: return(AsArray.CompareTo(other));

            case BsonType.Binary: return(((Byte[])RawValue).BinaryCompareTo((Byte[])other.RawValue));

            case BsonType.ObjectId: return(((ObjectId)RawValue).CompareTo((ObjectId)other.RawValue));

            case BsonType.Guid: return(((Guid)RawValue).CompareTo((Guid)other.RawValue));

            case BsonType.Boolean: return(((Boolean)RawValue).CompareTo((Boolean)other.RawValue));

            case BsonType.DateTime:
                var d0 = (DateTime)RawValue;
                var d1 = (DateTime)other.RawValue;
                if (d0.Kind != DateTimeKind.Utc)
                {
                    d0 = d0.ToUniversalTime();
                }
                if (d1.Kind != DateTimeKind.Utc)
                {
                    d1 = d1.ToUniversalTime();
                }
                return(d0.CompareTo(d1));

            default: throw new NotImplementedException();
            }
        }
 public virtual void testFunctionApply()
 {
     AsArray args = new AsArray("This is string", "This is another string");
     functionDefaultCallback((String)(args[0]), (String)(args[1]));
 }
예제 #16
0
 public virtual void setOnCompleteArgs(AsArray _value)
 {
     mOnCompleteArgs = _value;
 }
예제 #17
0
 public virtual void setOnUpdateArgs(AsArray _value)
 {
     mOnUpdateArgs = _value;
 }
예제 #18
0
        public virtual void advanceTime(float time)
        {
            if (time == 0 || (mRepeatCount == 1 && mCurrentTime == mTotalTime))
            {
                return;
            }
            int   i             = 0;
            float previousTime  = mCurrentTime;
            float restTime      = mTotalTime - mCurrentTime;
            float carryOverTime = time > restTime ? time - restTime : 0.0f;

            mCurrentTime = AsMath.min(mTotalTime, mCurrentTime + time);
            if (mCurrentTime <= 0)
            {
                return;
            }
            if (mCurrentCycle < 0 && previousTime <= 0 && mCurrentTime > 0)
            {
                mCurrentCycle++;
                if (mOnStart != null)
                {
                    mOnStart((float)(mOnStartArgs[0]));
                }
            }
            float ratio         = mCurrentTime / mTotalTime;
            bool  reversed      = mReverse && (mCurrentCycle % 2 == 1);
            int   numProperties = (int)(mStartValues.getLength());

            for (i = 0; i < numProperties; ++i)
            {
                if (AsGlobal.isNaN(mStartValues[i]))
                {
                    mStartValues[i] = ((AsObject)(mTarget)).getOwnProperty(mProperties[i]) as float;
                }
                float startValue      = mStartValues[i];
                float endValue        = mEndValues[i];
                float delta           = endValue - startValue;
                float transitionValue = reversed ? mTransitionFunc(1.0f - ratio) : mTransitionFunc(ratio);
                float currentValue    = startValue + transitionValue * delta;
                if (mRoundToInt)
                {
                    currentValue = AsMath.round(currentValue);
                }
                ((AsObject)(mTarget)).setOwnProperty(mProperties[i], currentValue);
            }
            if (mOnUpdate != null)
            {
                mOnUpdate((float)(mOnUpdateArgs[0]));
            }
            if (previousTime < mTotalTime && mCurrentTime >= mTotalTime)
            {
                if (mRepeatCount == 0 || mRepeatCount > 1)
                {
                    mCurrentTime = -mRepeatDelay;
                    mCurrentCycle++;
                    if (mRepeatCount > 1)
                    {
                        mRepeatCount--;
                    }
                    if (mOnRepeat != null)
                    {
                        mOnRepeat((float)(mOnRepeatArgs[0]));
                    }
                }
                else
                {
                    AsTransitionCallback onComplete = mOnComplete;
                    AsArray onCompleteArgs          = mOnCompleteArgs;
                    dispatchEventWith(AsEvent.REMOVE_FROM_JUGGLER);
                    if (onComplete != null)
                    {
                        onComplete((float)(onCompleteArgs[0]));
                    }
                }
            }
            if (carryOverTime != 0)
            {
                advanceTime(carryOverTime);
            }
        }
예제 #19
0
 public virtual void testArrayPop()
 {
     AsArray oneArray = new AsArray("a");
     String element = (String)(oneArray.pop());
 }
        public static void setBlendFactors(bool premultipliedAlpha, String blendMode)
        {
            AsArray blendFactors = AsBlendMode.getBlendFactors(blendMode, premultipliedAlpha);

            AsStarling.getContext().setBlendFactors((String)(blendFactors[0]), (String)(blendFactors[1]));
        }
예제 #21
0
 public virtual void setTabStops(AsArray _value)
 {
     throw new AsNotImplementedError();
 }
예제 #22
0
        public AsStarling(AsClass rootClass, bc.flash.display.AsStage stage, AsRectangle viewPort, AsStage3D stage3D, String renderMode, String profile)
        {
            if (stage == null)
            {
                throw new AsArgumentError("Stage must not be null");
            }
            if (rootClass == null)
            {
                throw new AsArgumentError("Root class must not be null");
            }
            if (viewPort == null)
            {
                viewPort = new AsRectangle(0, 0, stage.getStageWidth(), stage.getStageHeight());
            }
            if (stage3D == null)
            {
                stage3D = stage.getStage3Ds()[0];
            }
            makeCurrent();
            mRootClass     = rootClass;
            mViewPort      = viewPort;
            mStage3D       = stage3D;
            mStage         = new AsStage(viewPort.width, viewPort.height, stage.getColor());
            mNativeOverlay = new AsSprite();
            mNativeStage   = stage;
            mNativeStage.addChild(mNativeOverlay);
            mTouchProcessor      = new AsTouchProcessor(mStage);
            mJuggler             = new AsJuggler();
            mAntiAliasing        = 0;
            mSimulateMultitouch  = false;
            mEnableErrorChecking = false;
            mLastFrameTimestamp  = AsGlobal.getTimer() / 1000.0f;
            mPrograms            = new AsDictionary();
            mCustomData          = new AsDictionary();
            mSupport             = new AsRenderSupport();
            AsArray __touchEventTypes_ = getTouchEventTypes();

            if (__touchEventTypes_ != null)
            {
                foreach (String touchEventType in __touchEventTypes_)
                {
                    stage.addEventListener(touchEventType, onTouch, false, 0, true);
                }
            }
            stage.addEventListener(AsEvent.ENTER_FRAME, onEnterFrame, false, 0, true);
            stage.addEventListener(AsKeyboardEvent.KEY_DOWN, onKey, false, 0, true);
            stage.addEventListener(AsKeyboardEvent.KEY_UP, onKey, false, 0, true);
            stage.addEventListener(AsEvent.RESIZE, onResize, false, 0, true);
            if (mStage3D.getContext3D() != null && mStage3D.getContext3D().getDriverInfo() != "Disposed")
            {
                mShareContext = true;
                AsGlobal.setTimeout(initialize, 1);
            }
            else
            {
                mShareContext = false;
                mStage3D.addEventListener(AsEvent.CONTEXT3D_CREATE, onContextCreated, false, 1, true);
                mStage3D.addEventListener(AsErrorEvent.ERROR, onStage3DError, false, 1, true);
                try
                {
                    mStage3D.requestContext3D(renderMode);
                }
                catch (AsError e)
                {
                    showFatalError("Context3D error: " + e.message);
                }
            }
        }
예제 #23
0
 public virtual void setOnRepeatArgs(AsArray _value)
 {
     mOnRepeatArgs = _value;
 }
 public AsDelayedCall(AsDelayedCallback call, float delay, AsArray args)
 {
     reset(call, delay, args);
 }
        public virtual void testFunctionApply()
        {
            AsArray args = new AsArray("This is string", "This is another string");

            functionDefaultCallback((String)(args[0]), (String)(args[1]));
        }
예제 #26
0
 public virtual void testArrayPop()
 {
     AsArray oneArray = new AsArray("a");
     String  element  = (String)(oneArray.pop());
 }
예제 #27
0
 public virtual void setOnUpdateArgs(AsArray _value)
 {
     mOnUpdateArgs = _value;
 }
예제 #28
0
 public virtual void testArrayIndexer()
 {
     AsArray oneArray = new AsArray();
     oneArray[0] = "a";
     String val = (String)(oneArray[0]);
 }
예제 #29
0
 public virtual void setOnCompleteArgs(AsArray _value)
 {
     mOnCompleteArgs = _value;
 }
예제 #30
0
 public virtual void setTabStops(AsArray _value)
 {
     throw new AsNotImplementedError();
 }
 public AsDelayedCall(AsDelayedCallback call, float delay, AsArray args)
 {
     reset(call, delay, args);
 }
예제 #32
0
 public virtual void setOnStartArgs(AsArray _value)
 {
     mOnStartArgs = _value;
 }
예제 #33
0
 public virtual void setOnStartArgs(AsArray _value)
 {
     mOnStartArgs = _value;
 }
예제 #34
0
 public virtual void setOnRepeatArgs(AsArray _value)
 {
     mOnRepeatArgs = _value;
 }
예제 #35
0
        } // FTNode

        public A FoldRight <A>(Func <T, A, A> binOp, A initial)
        {
            return(AsArray.FoldRight(binOp, initial));
        } // FoldRight
예제 #36
0
        } // FoldRight

        public A FoldLeft <A>(Func <A, T, A> binOp, A initial)
        {
            return(AsArray.FoldLeft(binOp, initial));
        } // FoldLeft
        public virtual void advanceTime(float passedTime)
        {
            int     i       = 0;
            int     touchID = 0;
            AsTouch touch   = null;

            mElapsedTime = mElapsedTime + passedTime;
            if (mLastTaps.getLength() > 0)
            {
                for (i = (int)(mLastTaps.getLength() - 1); i >= 0; --i)
                {
                    if (mElapsedTime - mLastTaps[i].getTimestamp() > MULTITAP_TIME)
                    {
                        mLastTaps.splice(i, (uint)(1));
                    }
                }
            }
            while (mQueue.getLength() > 0)
            {
                sProcessedTouchIDs.setLength(sHoveringTouchData.setLength(0));
                AsVector <AsTouch> __touchs_ = mCurrentTouches;
                if (__touchs_ != null)
                {
                    foreach (AsTouch touch in __touchs_)
                    {
                        if (touch.getPhase() == AsTouchPhase.BEGAN || touch.getPhase() == AsTouchPhase.MOVED)
                        {
                            touch.setPhase(AsTouchPhase.STATIONARY);
                        }
                    }
                }
                while (mQueue.getLength() > 0 && sProcessedTouchIDs.indexOf(mQueue[mQueue.getLength() - 1][0]) == -1)
                {
                    AsArray touchArgs = mQueue.pop();
                    touch = getCurrentTouch(touchID);
                    if (touch != null && touch.getPhase() == AsTouchPhase.HOVER && touch.getTarget() != null)
                    {
                        sHoveringTouchData.push((As_AS_REST)(AsObject.createLiteralObject("touch", touch, "target", touch.getTarget())));
                    }
                    this.(int)(touchArgs[0]), (String)(touchArgs[1]), (float)(touchArgs[2]), (float)(touchArgs[3]), (float)(touchArgs[4]), (float)(touchArgs[5]), (float)(touchArgs[6]);
                    sProcessedTouchIDs.push(touchID);
                }
                AsTouchEvent      touchEvent    = new AsTouchEvent(AsTouchEvent.TOUCH, mCurrentTouches, mShiftDown, mCtrlDown);
                AsVector <Object> __touchDatas_ = sHoveringTouchData;
                if (__touchDatas_ != null)
                {
                    foreach (Object touchData in __touchDatas_)
                    {
                        if (((AsObject)(((AsObject)(touchData)).getOwnProperty("touch"))).getOwnProperty("target") != ((AsObject)(touchData)).getOwnProperty("target"))
                        {
                            touchEvent.dispatch(getBubbleChain((AsDisplayObject)(((AsObject)(touchData)).getOwnProperty("target")), sBubbleChain));
                        }
                    }
                }
                AsVector <int> __touchIDs_ = sProcessedTouchIDs;
                if (__touchIDs_ != null)
                {
                    foreach (int touchID in __touchIDs_)
                    {
                        getCurrentTouch(touchID).dispatchEvent(touchEvent);
                    }
                }
                for (i = (int)(mCurrentTouches.getLength() - 1); i >= 0; --i)
                {
                    if (mCurrentTouches[i].getPhase() == AsTouchPhase.ENDED)
                    {
                        mCurrentTouches.splice(i, (uint)(1));
                    }
                }
            }
            sBubbleChain.setLength(0);
        }
예제 #38
0
 public virtual void setNativeFilters(AsArray _value)
 {
     if(!mIsRenderedText)
     {
         throw new AsError("The TextField.nativeFilters property cannot be used on Bitmap fonts.");
     }
     mNativeFilters = _value.concat();
     mRequiresRedraw = true;
 }
예제 #39
0
 public virtual AsTween reset(Object target, float time, Object transition)
 {
     mTarget = target;
     mCurrentTime = 0;
     mTotalTime = AsMath.max(0.0001f, time);
     mDelay = mRepeatDelay = 0.0f;
     mOnStart = mOnUpdate = mOnComplete = null;
     mOnStartArgs = mOnUpdateArgs = mOnCompleteArgs = null;
     mRoundToInt = mReverse = false;
     mRepeatCount = 1;
     mCurrentCycle = -1;
     if(transition is String)
     {
         this.setTransition(transition as String);
     }
     else
     {
         if(transition is AsTransitionCallback)
         {
             this.setTransitionFunc(transition as AsTransitionCallback);
         }
         else
         {
             throw new AsArgumentError("Transition must be either a string or a function");
         }
     }
     if(mProperties != null)
     {
         mProperties.setLength(0);
     }
     else
     {
         mProperties = new AsVector<String>();
     }
     if(mStartValues != null)
     {
         mStartValues.setLength(0);
     }
     else
     {
         mStartValues = new AsVector<float>();
     }
     if(mEndValues != null)
     {
         mEndValues.setLength(0);
     }
     else
     {
         mEndValues = new AsVector<float>();
     }
     return this;
 }