October 29th, 2008 by Kyle
Tags: , ,
Posted in: Flex


I wrote a demo a while back for a customer to demonstrate the following scenario:

  • Tilelist populated by an arrayCollection of typed objects.
  • Tilelist has a custom itemRender that pops up a “view” of the data for the item in the tilelist that was clicked.
  • The popup can delete the related object from the dataProvider of the TileList, removing the popup and the corresponding item from the Tilelist.

    Here is the app:

    This movie requires Flash Player 9

    Download a zipfile containing the source to this sample.

    Browse the source of this example.

    Or continue into the blog entry to see the source:
    Read the rest of this post»




  • 3 Comments »

    October 13th, 2008 by Kyle
    Tags: , ,
    Posted in: ActionScript, Flex


    Last week in this post: http://blog.flexmonkeypatches.com/2008/10/08/flex-make-popup-follow-spawning-component-as-you-scroll/ I demonstrated one approach to on how one could make a popup follow the component that “spawned” it when the component was one of many (but not too many) that was in a VBox with vertical scrolling.

    The first approach felt a bit hacky and the showing and hiding of popups as they came in and out of view was a little fiddly. (My demo didn’t worry to much about exact “edge detection” to determine when the edge of a popup came in contact with the edge of the containing VBox…I’ll leave that to you if you decide to use that approach.)

    I came up with a second approach that feels a little cleaner.
    Basically, I overlay a canvas on top of my VBox and “addChild” popup components to the canvas (NOT using popupmanager) and scroll the canvas along with the VBox. Setting the isPopup property of the popup component allows me to drag the component around like you can a true popup.

    Check out the sample and the code:

    This movie requires Flash Player 9

    Download a zipfile containing the source to this sample.

    Browse the source of this example.

    Or continue into the blog entry to see the source:
    Read the rest of this post»




    No Comments »

    October 8th, 2008 by Kyle
    Tags: , ,
    Posted in: ActionScript, Flex


    A while back I had a request to show how one could make a popup follow the component that “spawned” it when the component was one of many (but not too many) that was in a VBox with vertical scrolling (kind of a “poor man’s” list control – which sometimes does have it’s place :) ).

    I actually came up with 2 solutions. The first I’ll post here. The second, I’ll post next week (after I clean it up a bit).

    In the first solution for each component added to the VBox that spawns a popup (via the popupmanager) a listener is added to react to the scroll event of the VBox which repositions the popup and additionally detects when the popup moves outside the bounds of the VBox, toggling it’s visibility to make it appear to “tuck under” the VBox as it’s spawning parent scrolls out of view.

    That is quite a mouthfull, but the sample and code will make it more clear:

    This movie requires Flash Player 9

    Download a zipfile containing the source to this sample.

    Browse the source of this example.

    Or continue into the blog entry to see the source:
    Read the rest of this post»




    2 Comments »

    October 4th, 2007 by Kyle
    Tags: , ,
    Posted in: Flex


    I had a customer that was wondering how they could close all the popup windows in one fell swoop. They knew they could keep track of each popup they created in say an array, then when they wanted to close them all, they could just iterate the array and close each one, but there must be a better way. And there is!

    The code and sample below show how to do this. Check the code comments for some interesting details.

    <mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
        viewSourceURL="wp-content/code/Flex2.0.1hf2/739stl_CloseAllPopUps/srcview/index.html">
        <mx:script>
            <!–[CDATA[
                import mx.managers.PopUpManager;
                import mx.managers.PopUpManagerChildList;

                private function openPopup(popUpScope:String):void{
                    var pop :P opup = Popup(PopUpManager.createPopUp(this,Popup,false,popUpScope));
                }

                private function closeAll():void{
                    // if you scope your popups to PopUpManagerChildList.POPUP
                    // this is all you should have to check to clear all popups
                    while(systemManager.popUpChildren.numChildren > 0){
                        PopUpManager.removePopUp(Popup(systemManager.popUpChildren.getChildAt(0)));
                    }
                    // if you scope your popups to other than PopUpManagerChildList.POPUP
                    // you need to scan this and check the class name to decide if you need to remove the child
                    for (var i:int = systemManager.numChildren-1;i>=0;i–){
                        trace(getQualifiedClassName(systemManager.getChildAt(i)));
                        if(getQualifiedClassName(systemManager.getChildAt(i))==‘Popup’){
                            systemManager.removeChildAt(i);
                        }
                    }
                }

            ]]–>
        </mx:script>
        <mx:button label="open popup – PopUpManagerChildList.POPUP" click="openPopup(PopUpManagerChildList.POPUP)">
        <mx:button label="open popup – PopUpManagerChildList.APPLICATION" click="openPopup(PopUpManagerChildList.APPLICATION)">
        <mx:button label="open popup – PopUpManagerChildList.PARENT" click="openPopup(PopUpManagerChildList.PARENT)">

        <mx:button label="close all" click="closeAll()">   

    </mx:button>
    </mx:button></mx:button></mx:button></mx:application>

    Browse the source of this example.
    Download a zipfile containing the source to this sample.

    This movie requires Flash Player 9

    Here is the simple popup that I use:

    <mx:titlewindow xmlns:mx="http://www.adobe.com/2006/mxml">
        width="400" height="300" x="100" y="100" showCloseButton="true" >

        <mx:text text="PopUp">

    </mx:text>
    </mx:titlewindow>




    3 Comments »

    May 7th, 2007 by Kyle
    Tags: , , , , ,
    Posted in: Flex


    I had a customer request some help in trying to restrict the movement of a popup window.
    Initially I was looked at all the drag and drop functionality, but realized that Panel and TitleWindow “roll their own” drag and drop stuff when used as a popup. I decided to take a simpler approach.

    Read the rest of this post»




    6 Comments »