Tim-
This is how I integrated a popup into a Cairngorm application. I'm not an expert by any means, so use caution if you follow my lead. In my application I click a "Send It" button that creates a popup window with a form in it. The following is the bones of how I do it with Cairngorm.

When I click the "Send It" button I dispatch a SendItEvent from a Canvas component like this:

public function sendIt():void {
    dispatchEvent(new SendItEvent(this));
}

this being the Canvas component that the "Send It" button is inside.
And the event passes along the DisplayObject:

package com.mydomain.controller {
   
    import org.nevis.cairngorm.control.CairngormEvent;

    import flash.display.DisplayObject;

    public class
SendItEvent extends CairngormEvent {
       
        public function SendItEvent( parentDisplay : DisplayObject ) {
            super(ApplicationController.EVENT_SENDIT);
            this.parentDisplay = parentDisplay;
        }
       
        public var parentDisplay : DisplayObject;
       
    }
}


I created a command class that communicates with a ViewHelper like this:

package com.mydomain.controller {
    
    import com.mydomain.model.ApplicationModel;
    import org.nevis.cairngorm.commands.Command;
    import org.nevis.cairngorm.control.CairngormEvent;

    

    public class SendItCommand implements Command {
        
        private static var model:ApplicationModel = ApplicationModel.getInstance();
        
        public function execute(cairngormEvent:CairngormEvent):void {
            var event:SendItEvent = cairngormEvent as SendItEvent;
           
model.popupViewHelper.showPopUpWindow( event.parentDisplay );
           
        }
        
    }
}


In my ApplicationModel constructor I have:

    popupState = POPUP_CLOSED;
    popupViewHelper = new PopUpViewHelper();


With two constants declared in that class:

    public static const POPUP_CLOSED : Number = 1;
    public static const VIEWING_POPUP : Number = 2;

And then my PopUpViewHelper class looks like this:

package com.mydomain.view {

    import org.nevis.cairngorm.view.ViewHelper;
    import com.
mydomain.model.ApplicationModel;
    import com.
mydomain.view.forms.SendItForm;
    import mx.containers.TitleWindow;
    import mx.managers.PopUpManager;
    import mx.core.Application;
    import mx.core.UIComponent;
   
    public class PopUpViewHelper extends ViewHelper {   
       
        public function PopUpViewHelper() {
            super();
        }   
             
           
        public function showPopUpWindow( parentDisplay : * ) : Boolean {
            if( ApplicationModel.getInstance().popupState != ApplicationModel.VIEWING_POPUP ) {
                if( (parentDisplay.window == null) || (parentDisplay.window != null & !Application.application.systemManager.rawChildren.contains(parentDisplay.window)) )
                    parentDisplay.window = TitleWindow(PopUpManager.createPopUp(parentDisplay, SendItForm, false));
                ApplicationModel.getInstance().popupState = ApplicationModel.VIEWING_POPUP;
                return true;
            } else {
                return false;
            }
        }
       
        public function closePopUpWindow( window : TitleWindow ) : void {
            if(window != null) PopUpManager.removePopUp( window );
            ApplicationModel.getInstance().popupState = ApplicationModel.POPUP_CLOSED;
        }
    }
}

So if there isn't a popup already open, the helper creates it. 

The only problem I've had with this, that I haven't been able to solve yet, is that the popup is sometimes hard to drag around. I'm not sure why, but sometimes I have to try to drag it a few times before it will actually respond to the mouse. Hope this helps. Let me know if you come up with a better way of doing it.
-Dustin


--- In [email protected], "Tim Hoff" <[EMAIL PROTECTED]> wrote:
>
> Got it to work with this:
>
> var myWindow:IFlexDisplayObject;
> var myParent:DisplayObject;
>
> myParent = Application.application.mainPanelView;
> myWindow = PopUpManager.createPopUp(myParent,SearchingPopupView,
> true);
>
> Now I just have to find a way to incorperate this without totally
> stepping all over Cairngorm.
>
> Again, thanks so much Dimitrios,
> Tim Hoff
>
> --- In [email protected], "Tim Hoff" <TimHoff@> wrote:
> >
> > That got rid of the compile error, but created the same error at
> run-
> > time.  Don't worry about it Dimitrios.  You've spent enough time
> on
> > this.  I'll keep trying.
> >
> > Much thanks,
> > Tim
> >
> > --- In [email protected], "Dimitrios Gianninas"
> > <dimitrios.gianninas@> wrote:
> > >
> > > wrap the MainPanelView like so:
> > >  
> > > DisplayObject(MainPanelView)
> > >  
> > > Dimitrios Gianninas
> > > RIA Developer
> > > Optimal Payments Inc.
> > >  
> > >
> > > ________________________________
> > >
> > > From: [email protected]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Tim Hoff
> > > Sent: Sunday, June 11, 2006 8:16 PM
> > > To: [email protected]
> > > Subject: [flexcoders] Re: Cairngorm createPopUp in a command
> > >
> > >
> > >
> > > In the command:  (Same thing if I move it to the ModelLocator)
> > >
> > > import org.ets.main.code.view.mainPanel.MainPanelView;
> > > import
> > org.ets.main.code.view.mainPanel.searching.SearchingPopupView;
> > > import mx.managers.PopUpManager;
> > > import mx.core.IFlexDisplayObject;
> > >
> > > public function execute(
> > >   var myWindow:IFlexDisplayObject;
> > >   myWindow = PopUpManager.createPopUp(MainPanelView,
> > >      SearchingPopupView, true);
> > > }
> > >
> > > The last line gives the error.
> > >
> > > This is the SearchingPopupView compnent:
> > >
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml
> > <http://www.adobe.com/2006/mxml> " cornerRadius="6"
> > >  styleName="plainPanel" headerHeight="0"
> > >  height="70" width="300" horizontalAlign="center"
> > verticalAlign="middle">
> > >  
> > >  <mx:Script>
> > >  <![CDATA[
> > >
> > >   import org.ets.main.code.model.ModelLocator;
> > >        
> > >  ]]>
> > >  </mx:Script>
> > >  
> > >  <mx:Spacer height="4"/>
> > >  <mx:Label text="{ ModelLocator.getInstance
> ().searchingMessage }"
> > fontWeight="bold" fontSize="11"/>
> > >  <mx:ProgressBar indeterminate="true" height="10"
> trackHeight="10"
> > barColor="#27568D" label=" "/>
> > > </mx:TitleWindow>
> > >
> > > -TH
> > >
> > > --- In [email protected], "Dimitrios Gianninas"
> > <dimitrios.gianninas@> wrote:
> > > >
> > > > it should work, too simple not too. What line gives the
> error...
> > paste the offending line.
> > > >
> > > > Dimitrios Gianninas
> > > > RIA Developer
> > > > Optimal Payments Inc.
> > > >
> > > >
> > > > ________________________________
> > > >
> > > > From: [email protected]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Tim Hoff
> > > > Sent: Sunday, June 11, 2006 8:01 PM
> > > > To: [email protected]
> > > > Subject: [flexcoders] Re: Cairngorm createPopUp in a command
> > > >
> > > >
> > > >
> > > > Well, I tried it both ways and am still getting the same
> compile
> > > > error. Sorry to be such a bother. I'll keep plugging away at
> it.
> > > >
> > > > Thanks Dimitrios,
> > > > Tim
> > > >
> > > > --- In [email protected] <mailto:flexcoders%
> > 40yahoogroups.com> , "Dimitrios Gianninas"
> > > > dimitrios.gianninas@ wrote:
> > > > >
> > > > > ok you are using Flex2... wasn't sure. Change to:
> > > > >
> > > > > var myWindow:IFlexDisplayObject
> > > > >
> > > > > And if you want, move the myWindow variable to the
> > ModelLocator.
> > > > >
> > > > > ModelLocator.myWindow = PopUpManager.createPopUp( .. );
> > > > >
> > > > >
> > > > > Dimitrios Gianninas
> > > > > RIA Developer
> > > > > Optimal Payments Inc.
> > > > >
> > > > >
> > > > > ________________________________
> > > > >
> > > > > From: [email protected] <mailto:flexcoders%
> > 40yahoogroups.com>
> > > > [mailto:[email protected] <mailto:flexcoders%
> > 40yahoogroups.com> ] On Behalf Of Tim Hoff
> > > > > Sent: Sunday, June 11, 2006 7:37 PM
> > > > > To: [email protected] <mailto:flexcoders%
> > 40yahoogroups.com>
> > > > > Subject: [flexcoders] Re: Cairngorm createPopUp in a command
> > > > >
> > > > >
> > > > >
> > > > > That doesn't want to work.
> > > > >
> > > > > Error: Implicit coersion of a value of type class to an
> > unrelated
> > > > > type flash.display.displayObject.
> > > > >
> > > > > I liked your idea of handling it in the ModelLocator. Any
> > chance
> > > > > you could show the code that your using to do it that way?
> > > > >
> > > > > Thanks again,
> > > > > Tim
> > > > >
> > > > > --- In [email protected] <mailto:flexcoders%
> > 40yahoogroups.com> <mailto:flexcoders%
> > > > 40yahoogroups.com> , "Dimitrios Gianninas"
> > > > > <dimitrios.gianninas@> wrote:
> > > > > >
> > > > > > Actually you don't even need to do that. You use case is
> > simpler
> > > > > (some code ommited):
> > > > > >
> > > > > > class MyCommand implements Command {
> > > > > > var myWindow:Object;
> > > > > >
> > > > > > public function execute() {
> > > > > > myWindow = PopUpManager.createPopUp( .. );
> > > > > > }
> > > > > >
> > > > > > public function onResult() {
> > > > > > PopUpManager.removePopUp( myWindow);
> > > > > > }
> > > > > >
> > > > > > public function onFault() {
> > > > > > PopUpManager.removePopUp( myWindow);
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > Dimitrios Gianninas
> > > > > > RIA Developer
> > > > > > Optimal Payments Inc.
> > > > > >
> > > > > >
> > > > > > ________________________________
> > > > > >
> > > > > > From: [email protected] <mailto:flexcoders%
> > 40yahoogroups.com> <mailto:flexcoders%
> > > > 40yahoogroups.com>
> > > > > [mailto:[email protected] <mailto:flexcoders%
> > 40yahoogroups.com> <mailto:flexcoders%
> > > > 40yahoogroups.com> ] On Behalf Of Tim Hoff
> > > > > > Sent: Sunday, June 11, 2006 7:17 PM
> > > > > > To: [email protected] <mailto:flexcoders%
> > 40yahoogroups.com> <mailto:flexcoders%
> > > > 40yahoogroups.com>
> > > > > > Subject: [flexcoders] Re: Cairngorm createPopUp in a
> command
> > > > > >
> > > > > >
> > > > > >
> > > > > > Dimitios,
> > > > > >
> > > > > > Could you elaberate a little with code? How are you
> creating
> > the
> > > > > > popup? And, by reference, do you mean import?
> > > > > >
> > > > > > Thanks,
> > > > > > Tim
> > > > > >
> > > > > > --- In [email protected] <mailto:flexcoders%
> > 40yahoogroups.com> <mailto:flexcoders%
> > > > 40yahoogroups.com> <mailto:flexcoders%
> > > > > 40yahoogroups.com> , "Dimitrios Gianninas"
> > > > > > <dimitrios.gianninas@> wrote:
> > > > > > >
> > > > > > > I've done this... In the ModelLocator keep a reference
> to
> > the
> > > > > > window that you will display, then you can access it from
> > > > wherever
> > > > > > you want, in your case the onResult and onFault events.
> > > > > > >
> > > > > > > Dimitrios Gianninas
> > > > > > > RIA Developer
> > > > > > > Optimal Payments Inc.
> > > > > > >
> > > > > > >
> > > > > > > ________________________________
> > > > > > >
> > > > > > > From: [email protected] <mailto:flexcoders%
> > 40yahoogroups.com> <mailto:flexcoders%
> > > > 40yahoogroups.com> <mailto:flexcoders%
> > > > > 40yahoogroups.com>
> > > > > > [mailto:[email protected] <mailto:flexcoders%
> > 40yahoogroups.com> <mailto:flexcoders%
> > > > 40yahoogroups.com> <mailto:flexcoders%
> > > > > 40yahoogroups.com> ] On Behalf Of Tim Hoff
> > > > > > > Sent: Sunday, June 11, 2006 5:52 PM
> > > > > > > To: [email protected] <mailto:flexcoders%
> > 40yahoogroups.com> <mailto:flexcoders%
> > > > 40yahoogroups.com> <mailto:flexcoders%
> > > > > 40yahoogroups.com>
> > > > > > > Subject: [flexcoders] Cairngorm createPopUp in a command
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Is it possible to create and remove a popup in a
> Cairngorm
> > > > > > command? I
> > > > > > > have a simple application that has two primary
> components;
> > > > > > sidePanel
> > > > > > > and mainPanel. Various child components are added to the
> > > > primary
> > > > > > > components, depending on the state of the application.
> > What I
> > > > > want
> > > > > > to
> > > > > > > do is create a popup in the mainPanel when the user
> clicks
> > a
> > > > > > search
> > > > > > > button in the sidePanel. The popup is a small component
> > that
> > > > > shows
> > > > > > a
> > > > > > > progress bar with a searching label. In the searching
> > command,
> > > > > > > executed with a cairngormEvent when the sidePanel search
> > > > button
> > > > > is
> > > > > > > clicked, I want to create the popup. onResult, remove
> the
> > > > popup
> > > > > > and
> > > > > > > change state to display a grid. onFault, remove the
> popup
> > and
> > > > > > display
> > > > > > > an Alert. I'm having a problem referencing the mainPanel
> > as
> > > > the
> > > > > > popup
> > > > > > > parent and listening for an event to remove the popup.
> > I've
> > > > > tried
> > > > > > > several different approaches with no success. If anyone
> > could
> > > > > get
> > > > > > me
> > > > > > > moving in the right direction, I would greatly
> appreciate
> > it.
> > > > > > >
> > > > > > > Thanks in advance,
> > > > > > > Tim Hoff
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > WARNING
> > > > > > > -------
> > > > > > > This electronic message and its attachments may contain
> > > > > > confidential, proprietary or legally privileged
> information,
> > > > which
> > > > > > is solely for the use of the intended recipient. No
> > privilege or
> > > > > > other rights are waived by any unintended transmission or
> > > > > > unauthorized retransmission of this message. If you are
> not
> > the
> > > > > > intended recipient of this message, or if you have
> received
> > it
> > > > in
> > > > > > error, you should immediately stop reading this message
> and
> > > > delete
> > > > > > it and all attachments from your system. The reading,
> > > > > distribution,
> > > > > > copying or other use of this message or its attachments by
> > > > > > unintended recipients is unauthorized and may be unlawful.
> > If
> > > > you
> > > > > > have received this e-mail in error, please notify the
> sender.
> > > > > > >
> > > > > > > AVIS IMPORTANT
> > > > > > > --------------
> > > > > > > Ce message électronique et ses pièces jointes peuvent
> > contenir
> > > > > des
> > > > > > renseignements confidentiels, exclusifs ou légalement
> > > > privilégiés
> > > > > > destinés au seul usage du destinataire visé. L'expéditeur
> > > > original
> > > > > > ne renonce à aucun privilège ou à aucun autre droit si le
> > > > présent
> > > > > > message a été transmis involontairement ou s'il est
> > retransmis
> > > > > sans
> > > > > > son autorisation. Si vous n'êtes pas le destinataire visé
> du
> > > > > > présent message ou si vous l'avez reçu par erreur,
> veuillez
> > > > cesser
> > > > > > immédiatement de le lire et le supprimer, ainsi que toutes
> > ses
> > > > > > pièces jointes, de votre système. La lecture, la
> > distribution,
> > > > la
> > > > > > copie ou tout autre usage du présent message ou de ses
> > pièces
> > > > > > jointes par des personnes autres que le destinataire visé
> ne
> > > > sont
> > > > > > pas autorisés et pourraient être illégaux. Si vous avez
> reçu
> > ce
> > > > > > courrier électronique par erreur, veuillez en aviser
> > > > l'expéditeur.
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to