PDA

View Full Version : PopUp buttons...


dColumbus
10-04-2007, 11:45 PM
I've got this script that creates a popUp and adds a controlBar and two buttons:


<mx:Script>
<![CDATA[
import mx.states.SetEventHandler;

import mx.managers.PopUpManager;
import mx.containers.TitleWindow;
import mx.containers.ControlBar;
import mx.controls.TextArea;
import mx.controls.Button;
import mx.events.CloseEvent;

private var _window:TitleWindow;

private function showWindow():void
{
_window = TitleWindow(PopUpManager.createPopUp(this, TitleWindow, true));

// create the textArea
var textArea:TextArea = new TextArea();
textArea.text = "This is a test with some text that really means nothing.";
textArea.height = 200;

// create the controlBar and buttons
var controlBar:ControlBar = new ControlBar;
var proceedBtn:Button = new Button;
proceedBtn.label = "Proceed";
var cancelBtn:Button = new Button;
cancelBtn.label = "Cancel";
cancelBtn.addEventListener(MouseEvent.CLICK, closeHandler);

// add the buttons to the controlBar
controlBar.addChild(proceedBtn);
controlBar.addChild(cancelBtn);

// add the controlBar and the textArea to the _window
_window.addChild(textArea);
_window.addChild(controlBar);

//_window.showCloseButton = true;
_window.addEventListener(CloseEvent.CLOSE, closeHandler);

// center _window
centerIt();
}

private function centerIt():void {
PopUpManager.centerPopUp(_window);
}

private function closeHandler(event:MouseEvent):void
{
PopUpManager.removePopUp(_window);
}

]]>
</mx:Script>


The problem is, if you use this code and take a look, the buttons are being added within the TitleWindow text area... not below. now, if I create the exact same with this code:


<mx:TitleWindow>
<mx:ControlBar>
<mx:Button label="test">
</mx:Button>
<mx:Button label="test2">
</mx:Button>
</mx:ControlBar>
</mx:TitleWindow>


The buttons appear below the TitleWindow text area... which is what i need to accomplish.

I thank you in advance.

drkstr
10-06-2007, 12:19 PM
When you create the components in the mxml, is it inheriting a layout property from a parent (IE. layout="vertical"). I think I remember reading somewhere that if not set, it will default to vertical. Maybe you should add the controls as a child to a VBox container.

Hope this helps,
...aaron