override protected function addChildren():void { var local1:int; var local5:TabButtonUI;…
- User
override protected function addChildren():void { var _local_1:int; var _local_5:TabButtonUI; super.addChildren(); this._topPanelBitmap = new Bitmap(Images.LOBBY_PANEL_TOP); addChild(this._topPanelBitmap); this._playerAvatar = new PlayerAvatarUI(this); this._coinBitmap = new Bitmap(Images.ICON_COIN); this._coinBitmap.x = 41; this._coinBitmap.y = -1; addChild(this._coinBitmap); this._coinsLabel = (new LabelUI(this, 70, 4).setAutoSize(false).setVerticalAlign(LabelUI.TOP_ALIGN).setSystemFont("Verdana", 13, 4070927).addFilter(UIStyle.COINS_FILTER).setSize(76, 20) as LabelUI); this._buyCoinsButton = (new ButtonUI(this, 152, 3).setImage(Images.BUTTON_BUY_COINS).setSize(22, 22) as ButtonUI); this._experienceBar = new ExperienceBarUI(this, 199, 8); this._levelViewer = new LevelViewerUI(this, 181, 2); this._lobbyPagesPanel = new PanelUI(this); this._lobbyPagesTabs = new Vector.(3, true); var _local_1:int; while (_local_1 < this._lobbyPagesTabs.length) { _local_5 = new TabButtonUI(this._lobbyPagesPanel); _local_5.tag = _local_1; _local_5.groupName = "lobbyPages"; _local_5.setSize(127, 48); _local_5.setImage(Images.TAB_LOBBY_ITEMS[_local_1]); _local_5.y = 29; this._lobbyPagesTabs[_local_1] = _local_5; _local_1++; }; this._lobbyPagesTabs[0].x = 77; this._lobbyPagesTabs[1].x = 0xFF; this._lobbyPagesTabs[2].x = 434; this._soundButton = (new ToggleButtonUI(this, 718, 2).setImage(Images.BUTTON_GAME_SOUND).setToolTipText(Text.getValue("ui_tooltip_sound")).setToolTipDirection(UI.BOTTOM_TOOLTIP_DIRECTION).setSize(25, 25) as ToggleButtonUI); this._helpButton = (new ButtonUI(this, 743, 2).setImage(Images.BUTTON_GAME_HELP).setToolTipText(Text.getValue("ui_tooltip_help")).setToolTipDirection(UI.BOTTOM_TOOLTIP_DIRECTION).setSize(25, 25) as ButtonUI); this._aboutButton = (new ButtonUI(this, 0x0300, 2).setImage(Images.BUTTON_ABOUT).setToolTipText(Text.getValue("ui_tooltip_authors")).setToolTipDirection(UI.BOTTOM_TOOLTIP_DIRECTION).setSize(25, 25) as ButtonUI); this._bottomPanelBitmap = new Bitmap(Images.LOBBY_PANEL_BOTTOM); this._bottomPanelBitmap.y = 532; addChild(this._bottomPanelBitmap); this._randomFriendViewer = (new FriendViewerUI(this, 10, 537).setToolTipDirection(UI.TOP_TOOLTIP_DIRECTION) as FriendViewerUI); var _local_2:RepeatButtonUI = (new RepeatButtonUI(this, 92, 555).setImage(Images.BUTTON_SCROLL_LEFT).setSize(24, 64) as RepeatButtonUI); var _local_3:RepeatButtonUI = (new RepeatButtonUI(this, 766, 555).setImage(Images.BUTTON_SCROLL_RIGHT).setSize(24, 64) as RepeatButtonUI); var _local_4:ScrollUI = new ScrollUI(this).setPrevButton(_local_2).setNextButton(_local_3); this._friendList = (new FriendListUI(this, 124, 537).setSelectable(false).setScroll(_local_4) as FriendListUI); new DefaultToolTipUI(this); } как _topPanelBitmap выставить по центру
- Assistant
To center the
_topPanelBitmapin theaddChildrenfunction, you can calculate the x position based on the width of the stage and the width of the_topPanelBitmap. Here's an example of how you can modify the code:actionscriptoverride protected function addChildren():void { // ... this._topPanelBitmap = new Bitmap(Images.LOBBY_PANEL_TOP); this._topPanelBitmap.x = (stage.stageWidth - this._topPanelBitmap.width) / 2; // Center horizontally addChild(this._topPanelBitmap); // ... }