private void onEnterFrame(AsEvent _event)
 {
     if (mStarted && !mShareContext)
     {
         nextFrame();
     }
 }
 public virtual void broadcastEvent(AsEvent _event)
 {
     if(_event.getBubbles())
     {
         throw new AsArgumentError("Broadcast of bubbling events is prohibited");
     }
     dispatchEventOnChildren(_event);
 }
 public override void dispatchEvent(AsEvent _event)
 {
     if (mContentLoaderInfo.hasEventListener(_event.getType()))
     {
         mContentLoaderInfo.dispatchEvent(_event);
     }
     else
     {
         base.dispatchEvent(_event);
     }
 }
 private void onContextCreated(AsEvent _event)
 {
     if (!AsStarling.getHandleLostContext() && mContext != null)
     {
         stop();
         _event.stopImmediatePropagation();
         showFatalError("Fatal error: The application lost the device context!");
         AsGlobal.trace("[Starling] The device context was lost. " + "Enable 'Starling.handleLostContext' to avoid this error.");
     }
     else
     {
         initialize();
     }
 }
 public override void dispatchEvent(AsEvent _event)
 {
     if(_event is AsTouchEvent)
     {
         AsTouchEvent touchEvent = _event as AsTouchEvent;
         if(touchEvent.getTimestamp() == mLastTouchTimestamp)
         {
             return;
         }
         else
         {
             mLastTouchTimestamp = touchEvent.getTimestamp();
         }
     }
     base.dispatchEvent(_event);
 }
 public override void dispatchEvent(AsEvent _event)
 {
     if(_event is AsTouchEvent)
     {
         AsTouchEvent touchEvent = ((_event is AsTouchEvent) ? ((AsTouchEvent)(_event)) : null);
         if((touchEvent.getTimestamp() == mLastTouchTimestamp))
         {
             return;
         }
         else
         {
             mLastTouchTimestamp = touchEvent.getTimestamp();
         }
     }
     base.dispatchEvent(_event);
 }
Beispiel #7
0
        private void onKey(AsEvent evt)
        {
            AsKeyboardEvent _event = ((AsKeyboardEvent)(evt));

            if (_event.getKeyCode() == 17 || _event.getKeyCode() == 15)
            {
                bool wasCtrlDown = mCtrlDown;
                mCtrlDown = _event.getType() == AsKeyboardEvent.KEY_DOWN;
            }
            else
            {
                if (_event.getKeyCode() == 16)
                {
                    mShiftDown = _event.getType() == AsKeyboardEvent.KEY_DOWN;
                }
            }
        }
Beispiel #8
0
        public virtual void dispatchEvent(AsEvent _event)
        {
            AsVector <AsEventListenerCallback> listeners = (AsVector <AsEventListenerCallback>)(mEventListeners != null ? mEventListeners[_event.getType()] : null);

            if (listeners == null && !_event.getBubbles())
            {
                return;
            }
            AsEventDispatcher previousTarget = _event.getTarget();

            if (previousTarget == null || _event.getCurrentTarget() != null)
            {
                _event.setTarget(this);
            }
            bool stopImmediatePropagation = false;
            uint numListeners             = (uint)(listeners == null ? 0 : listeners.getLength());

            if (numListeners != 0)
            {
                _event.setCurrentTarget(this);
                int i = 0;
                for (; i < numListeners; ++i)
                {
                    AsEventListenerCallback listener = listeners[i];
                    listener(_event);
                    if (_event.getStopsImmediatePropagation())
                    {
                        stopImmediatePropagation = true;
                        break;
                    }
                }
            }
            if (!stopImmediatePropagation && _event.getBubbles() && !_event.getStopsPropagation() && this is AsDisplayObject)
            {
                AsDisplayObject targetDisplayObject = this as AsDisplayObject;
                if (targetDisplayObject.getParent() != null)
                {
                    _event.setCurrentTarget(null);
                    targetDisplayObject.getParent().dispatchEvent(_event);
                }
            }
            if (previousTarget != null)
            {
                _event.setTarget(previousTarget);
            }
        }
 public virtual void dispatchEvent(AsEvent _event)
 {
     AsVector<AsEventListenerCallback> listeners = (AsVector<AsEventListenerCallback>)(((mEventListeners != null) ? (mEventListeners[_event.getType()]) : (null)));
     if(((listeners == null) && !(_event.getBubbles())))
     {
         return;
     }
     AsEventDispatcher previousTarget = _event.getTarget();
     if(((previousTarget == null) || (_event.getCurrentTarget() != null)))
     {
         _event.setTarget(this);
     }
     bool stopImmediatePropagation = false;
     uint numListeners = (uint)((((listeners == null)) ? (0) : (listeners.getLength())));
     if((numListeners != 0))
     {
         _event.setCurrentTarget(this);
         int i = 0;
         for (; (i < numListeners); ++i)
         {
             AsEventListenerCallback listener = listeners[i];
             listener(_event);
             if(_event.getStopsImmediatePropagation())
             {
                 stopImmediatePropagation = true;
                 break;
             }
         }
     }
     if((((!(stopImmediatePropagation) && _event.getBubbles()) && !(_event.getStopsPropagation())) && this is AsDisplayObject))
     {
         AsDisplayObject targetDisplayObject = ((this is AsDisplayObject) ? ((AsDisplayObject)(this)) : null);
         if((targetDisplayObject.getParent() != null))
         {
             _event.setCurrentTarget(null);
             targetDisplayObject.getParent().dispatchEvent(_event);
         }
     }
     if(previousTarget != null)
     {
         _event.setTarget(previousTarget);
     }
 }
 public virtual void dispatchEvent(AsEvent _event)
 {
     AsVector<AsEventListenerCallback> listeners = (AsVector<AsEventListenerCallback>)(mEventListeners != null ? mEventListeners[_event.getType()] : null);
     if(listeners == null && !_event.getBubbles())
     {
         return;
     }
     AsEventDispatcher previousTarget = _event.getTarget();
     if(previousTarget == null || _event.getCurrentTarget() != null)
     {
         _event.setTarget(this);
     }
     bool stopImmediatePropagation = false;
     uint numListeners = (uint)(listeners == null ? 0 : listeners.getLength());
     if(numListeners != 0)
     {
         _event.setCurrentTarget(this);
         int i = 0;
         for (; i < numListeners; ++i)
         {
             AsEventListenerCallback listener = listeners[i];
             listener(_event);
             if(_event.getStopsImmediatePropagation())
             {
                 stopImmediatePropagation = true;
                 break;
             }
         }
     }
     if(!stopImmediatePropagation && _event.getBubbles() && !_event.getStopsPropagation() && this is AsDisplayObject)
     {
         AsDisplayObject targetDisplayObject = this as AsDisplayObject;
         if(targetDisplayObject.getParent() != null)
         {
             _event.setCurrentTarget(null);
             targetDisplayObject.getParent().dispatchEvent(_event);
         }
     }
     if(previousTarget != null)
     {
         _event.setTarget(previousTarget);
     }
 }
 private void onTouch(AsEvent evt)
 {
     AsTouchEvent _event = ((AsTouchEvent)(evt));
     AsMouse.setCursor(_event.interactsWith(this) ? AsMouseCursor.BUTTON : AsMouseCursor.AUTO);
 }
 public virtual void dispatchEventOnChildren(AsEvent _event)
 {
     dispatchEvent(_event);
 }
 private void onKey(AsEvent evt)
 {
     AsKeyboardEvent _event = ((AsKeyboardEvent)(evt));
     if(((_event.getKeyCode() == 17) || (_event.getKeyCode() == 15)))
     {
         bool wasCtrlDown = mCtrlDown;
         mCtrlDown = (_event.getType() == AsKeyboardEvent.KEY_DOWN);
     }
     else
     {
         if((_event.getKeyCode() == 16))
         {
             mShiftDown = (_event.getType() == AsKeyboardEvent.KEY_DOWN);
         }
     }
 }
        private void onTouch(AsEvent _event)
        {
            if (!mStarted)
            {
                return;
            }
            float  globalX  = 0;
            float  globalY  = 0;
            int    touchID  = 0;
            String phase    = null;
            float  pressure = 1.0f;
            float  width    = 1.0f;
            float  height   = 1.0f;

            if (_event is AsMouseEvent)
            {
                AsMouseEvent mouseEvent = _event as AsMouseEvent;
                globalX = mouseEvent.getStageX();
                globalY = mouseEvent.getStageY();
                touchID = 0;
                if (_event.getType() == AsMouseEvent.MOUSE_DOWN)
                {
                    mLeftMouseDown = true;
                }
                else
                {
                    if (_event.getType() == AsMouseEvent.MOUSE_UP)
                    {
                        mLeftMouseDown = false;
                    }
                }
            }
            else
            {
                AsTouchEvent touchEvent = _event as AsTouchEvent;
                globalX  = touchEvent.getStageX();
                globalY  = touchEvent.getStageY();
                touchID  = touchEvent.getTouchPointID();
                pressure = touchEvent.getPressure();
                width    = touchEvent.getSizeX();
                height   = touchEvent.getSizeY();
            }
            switch (_event.getType())
            {
            case AsTouchEvent.TOUCH_BEGIN:
                phase = AsTouchPhase.BEGAN;
                break;

            case AsTouchEvent.TOUCH_MOVE:
                phase = AsTouchPhase.MOVED;
                break;

            case AsTouchEvent.TOUCH_END:
                phase = AsTouchPhase.ENDED;
                break;

            case AsMouseEvent.MOUSE_DOWN:
                phase = AsTouchPhase.BEGAN;
                break;

            case AsMouseEvent.MOUSE_UP:
                phase = AsTouchPhase.ENDED;
                break;

            case AsMouseEvent.MOUSE_MOVE:
                phase = mLeftMouseDown ? AsTouchPhase.MOVED : AsTouchPhase.HOVER;
                break;
            }
            globalX = mStage.getStageWidth() * (globalX - mViewPort.x) / mViewPort.width;
            globalY = mStage.getStageHeight() * (globalY - mViewPort.y) / mViewPort.height;
            mTouchProcessor.enqueue(touchID, phase, globalX, globalY, pressure, width, height);
        }
 private void onEnterFrame(AsEvent _event)
 {
     if(mStarted && !mShareContext)
     {
         nextFrame();
     }
 }
 private void onContextCreated(AsEvent _event)
 {
     if(!AsStarling.getHandleLostContext() && mContext != null)
     {
         stop();
         _event.stopImmediatePropagation();
         showFatalError("Fatal error: The application lost the device context!");
         AsGlobal.trace("[Starling] The device context was lost. " + "Enable 'Starling.handleLostContext' to avoid this error.");
     }
     else
     {
         initialize();
     }
 }
 private void onTouch(AsEvent _event)
 {
     if(!mStarted)
     {
         return;
     }
     float globalX = 0;
     float globalY = 0;
     int touchID = 0;
     String phase = null;
     float pressure = 1.0f;
     float width = 1.0f;
     float height = 1.0f;
     if(_event is AsMouseEvent)
     {
         AsMouseEvent mouseEvent = _event as AsMouseEvent;
         globalX = mouseEvent.getStageX();
         globalY = mouseEvent.getStageY();
         touchID = 0;
         if(_event.getType() == AsMouseEvent.MOUSE_DOWN)
         {
             mLeftMouseDown = true;
         }
         else
         {
             if(_event.getType() == AsMouseEvent.MOUSE_UP)
             {
                 mLeftMouseDown = false;
             }
         }
     }
     else
     {
         AsTouchEvent touchEvent = _event as AsTouchEvent;
         globalX = touchEvent.getStageX();
         globalY = touchEvent.getStageY();
         touchID = touchEvent.getTouchPointID();
         pressure = touchEvent.getPressure();
         width = touchEvent.getSizeX();
         height = touchEvent.getSizeY();
     }
     switch(_event.getType())
     {
         case AsTouchEvent.TOUCH_BEGIN:
         phase = AsTouchPhase.BEGAN;
         break;
         case AsTouchEvent.TOUCH_MOVE:
         phase = AsTouchPhase.MOVED;
         break;
         case AsTouchEvent.TOUCH_END:
         phase = AsTouchPhase.ENDED;
         break;
         case AsMouseEvent.MOUSE_DOWN:
         phase = AsTouchPhase.BEGAN;
         break;
         case AsMouseEvent.MOUSE_UP:
         phase = AsTouchPhase.ENDED;
         break;
         case AsMouseEvent.MOUSE_MOVE:
         phase = mLeftMouseDown ? AsTouchPhase.MOVED : AsTouchPhase.HOVER;
         break;
     }
     globalX = mStage.getStageWidth() * (globalX - mViewPort.x) / mViewPort.width;
     globalY = mStage.getStageHeight() * (globalY - mViewPort.y) / mViewPort.height;
     mTouchProcessor.enqueue(touchID, phase, globalX, globalY, pressure, width, height);
 }
 public override void dispatchEventOnChildren(AsEvent _event)
 {
     getChildEventListeners(this, _event.getType(), sListenersList);
     int numListeners = (int)(sListenersList.getLength());
     int i = 0;
     for (; i < numListeners; ++i)
     {
         sListenersList[i].dispatchEvent(_event);
     }
     sListenersList.setLength(0);
 }
 public override void dispatchEventOnChildren(AsEvent _event)
 {
     AsVector<AsDisplayObject> listeners = new AsVector<AsDisplayObject>();
     getChildEventListeners(this, _event.getType(), listeners);
     int numListeners = (int)(listeners.getLength());
     int i = 0;
     for (; (i < numListeners); ++i)
     {
         listeners[i].dispatchEvent(_event);
     }
 }