I found a simple confirmWindow popup on someone's blog that I wanted
to abstract parts of it for re-use (set message, labels, etc).

(aside: wonder why there isn't a confirmWindow control built in?)

first guess didn't work: I obviously can't fake it and use composition
with mxml to create it (below)

so...

* have to create this completely in AS3, yes?

* my confirmWindow extends titleWindow?

* button declarations become:
private var_btnLeft:Button;
_btnLeft = new Button; 
... is this same for containers (HBox, etc)?

* if I have additional helper classes, can I put them in the same
package in the same .as file (like C#) or do they have to be in
separate files (like Java) and imported?

many thanx




[incorrect version just to illustrate what I'm trying to customise]
- still deciding whether to return 'yes/no'or a boolean

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml";
title="Confirmation" creationComplete="doInit();">
    <mx:Script>
    <![CDATA[
    import mx.managers.PopUpManager;

    private function doInit():void {
    PopUpManager.centerPopUp(this);
    }

    private function confirm(response:String):void {
    var event:Event = new Event("selected" + response);
    dispatchEvent(event);
    PopUpManager.removePopUp(this);
    }
    
    // by convention, use "_" prefix for private variables
    [Bindable]
    private var _message:String = "";
    [Bindable]
    private var _leftButtonLabel:String = "";
    [Bindable]
    private var _rightButtonLabel:String = "";
    
    public function set message(val:String):void
    {
        _message = val; 
    }
 
    public function set leftButtonLabel(val:String):void
    {
        _leftButtonLabel = val;
    }   
    
    public function set rightButtonLabel(val:String):void
    {
        _rightButtonLabel = val;
    }
    
    ]]>
    </mx:Script>

    <mx:VBox horizontalAlign="center">
    <mx:Text text="{message}" height="40" width="170" fontSize="12"/>
    </mx:VBox>
    <mx:ControlBar horizontalAlign="center">
    <mx:HBox>
    <mx:Button id="btnLeft" click="confirm('Yes');"
label="{_leftButtonLabel}"/>
    <mx:Button id="btnRight" click="confirm('No');"
label="{_rightButtonLabel}"/>
    </mx:HBox>
    </mx:ControlBar>
</mx:TitleWindow>

Reply via email to