Esempio n. 1
0
        override public void ConstructFromXML(XML cxml)
        {
            base.ConstructFromXML(cxml);

            XML xml = cxml.GetNode("ComboBox");

            string str;

            _buttonController = GetController("button");
            _titleObject      = GetChildByName("title") as GTextField;

            str = (string)xml.GetAttribute("dropdown");
            if (string.IsNullOrEmpty(str))
            {
                Debug.Log(this.resourceURL + ": 需要定义下拉框资源");
                return;
            }

            _dropdownObject = UIPackage.CreateObjectFromURL(str) as GComponent;
            if (_dropdownObject == null)
            {
                Debug.Log(this.resourceURL + ": 下拉框必须为元件");
                return;
            }

            _list = _dropdownObject.GetChildByName("list") as GList;
            if (_list == null)
            {
                Debug.Log(this.resourceURL + ": 下拉框的弹出元件里必须包含名为list的列表");
                return;
            }
            _list.AddEventListener(ItemEvent.CLICK, __clickItemObsolete);
            _list.onClickItem.Add(__clickItem);

            _list.AddRelation(_dropdownObject, RelationType.Width);
            _dropdownObject.AddRelation(_list, RelationType.Height);

            _displayObject.AddEventListenerObsolete(MouseEvent.ROLL_OVER, __rolloverObsolete);
            _displayObject.AddEventListenerObsolete(MouseEvent.ROLL_OUT, __rolloutObsolete);
            _displayObject.AddEventListenerObsolete(MouseEvent.MOUSE_DOWN, __mousedown);

            displayObject.onRollOver.Add(__rollover);
            displayObject.onRollOut.Add(__rollout);
            displayObject.onTouchBegin.Add(__touchBegin);
        }
Esempio n. 2
0
        public PopupMenu(int width = 100, string resourceURL = null)
        {
            if (resourceURL == null)
            {
                resourceURL = UIConfig.popupMenu;
            }

            _contentPane = UIPackage.CreateObjectFromURL(resourceURL).asCom;
            _contentPane.AddEventListener(EventContext.ADDED_TO_STAGE, __addedToStage);

            _contentPane.width = width;
            _list = _contentPane.GetChildByName("list").asList;
            _list.RemoveChildrenToPool();

            _list.AddRelation(_contentPane, RelationType.Width);
            _contentPane.AddRelation(_list, RelationType.Height);

            _list.AddEventListener(ItemEvent.CLICK, __clickItem);
        }
Esempio n. 3
0
        public static GObject NewObject(string type, AppContext context)
        {
            GObject cls = null;

            switch (type)
            {
            case "image":
                cls = new GImage();
                break;

            case "movieclip":
                cls = new GMovieClip();
                break;

            case "swf":
                cls = new GSwfObject();
                break;

            case "jta":
                cls = new GJtaObject();
                break;

            case "component":
                cls = new GComponent();
                break;

            case "text":
                cls = new GTextField();
                break;

            case "group":
                cls = new GGroup();
                break;

            case "list":
                cls = new GList();
                break;

            case "graph":
                cls = new GGraph();
                break;

            case "loader":
                cls = new GLoader();
                break;

            //component derived
            case "Button":
                cls = new GButton();
                break;

            case "Label":
                cls = new GLabel();
                break;

            case "ProgressBar":
                cls = new GProgressBar();
                break;

            case "Slider":
                cls = new GSlider();
                break;

            case "ScrollBar":
                cls = new GScrollBar();
                break;

            case "ComboBox":
                cls = new GComboBox();
                break;
            }
            cls.OnCreate(context);
            return(cls);
        }