예제 #1
0
        private void createTextField()
        {
            if (mTextField == null)
            {
                //mTextField = new TextField(mTextBounds.width, mTextBounds.height, "");
                mTextField            = new BitmapTextField();
                mTextField.textFormat = mTextFormat;

                /*mTextField.vAlign = VAlign.CENTER;
                 * mTextField.hAlign = HAlign.CENTER;
                 * mTextField.touchable = false;
                 * mTextField.autoScale = true;*/
                mContents.addChild(mTextField);
            }

            mTextField.width  = mTextBounds.width;
            mTextField.height = mTextFormat.size;
            mTextField.x      = mTextBounds.x;
            mTextField.y      = (mTextBounds.height * 0.5f) - (mTextField.height * 0.75f);
        }
예제 #2
0
        public Button(DisplayObjectX upState, string text = "", DisplayObjectX downState = null, TextFormat format = null)
        {
            //if (upState == null) throw new ErrorEvent("Texture cannot be null");

            mParent     = upState.parent;
            mUpState    = upState;
            mDownState  = downState != null ? downState : upState;
            mBackground = upState;
            mTextFormat = format;

            mScaleWhenDown     = 0.9f;
            mAlphaWhenDisabled = 0.5f;
            mEnabled           = true;
            mIsDown            = false;
            mUseHandCursor     = true;
            mTextBounds        = new RectangleX(0, 0, upState.width, upState.height);

            mContents = new DisplayObjectContainerX();
            mContents.addChild(mBackground);
            addChild(mContents);

            //addEventListener(TouchEvent.TOUCH, onTouch);
            addEventListener(MouseEventX.MOUSE_DOWN, onMouseDown);

            if (text.Length > 0)
            {
                this.text = text;
            }

            this.x    = upState.x;
            this.y    = upState.y;
            upState.x = upState.y = 0;

            if (mParent != null)
            {
                mParent.addChild(this);
            }
        }