{"id":108,"date":"2009-03-04T10:13:54","date_gmt":"2009-03-04T17:13:54","guid":{"rendered":"http:\/\/www.nayansavla.com\/blog\/?p=108"},"modified":"2009-04-02T09:12:39","modified_gmt":"2009-04-02T16:12:39","slug":"using-popupmanager-in-flex","status":"publish","type":"post","link":"https:\/\/www.nayansavla.com\/blog\/?p=108","title":{"rendered":"Using PopupManager in Flex"},"content":{"rendered":"<p>PopupManager is another utility class in Flex which i really love to use as often as i can. With big projects when you need to lay views on top of other views and things like that it really comes in handy.<\/p>\n<p>\u00a0<br \/>\n<!-- google_ad_section_start --><br \/>\nWithin the Flex framework this class is also used by some of components like Alert, Combobox. If you take a look at the <a href=\"http:\/\/www.nayansavla.com\/blog\/?p=52\" target=\"_blank\">Audiolife widget<\/a> i have developed, this class has really saved my life there. The merchant descriptions, album descriptions are mxml components displayed using PopupManager.\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>Any class which\u00a0implements\u00a0the Interface IFlexDisplayObject can be added and removed using PopUpManager, this is how i\u00a0achieve\u00a0it.\u00a0<\/p>\n<p>\u00a0<\/p>\n<div class=\"codecolorer-container actionscript default\" style=\"overflow:auto;white-space:nowrap;width:435px;height:300px;\"><div class=\"actionscript codecolorer\"><span class=\"kw2\">var<\/span> albumDetails:AlbumDetails = <span class=\"kw2\">new<\/span> AlbumDetails<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span>;<br \/>\n<br \/>\n<span class=\"co1\">\/\/create the class which needs to be added this is mxml component inheriting Canvas<\/span><br \/>\n<br \/>\nPopUpManager.<span class=\"me1\">addPopUp<\/span><span class=\"br0\">&#40;<\/span>albumDetails,model.<span class=\"me1\">popUpHolder<\/span><span class=\"br0\">&#41;<\/span>;<br \/>\n<br \/>\n<span class=\"co1\">\/\/add it on top of everything and position it within the holder, it just needs a parent display object<\/span><br \/>\n<br \/>\nmodel.<span class=\"me1\">currPopUp<\/span> = albumDetails as IFlexDisplayObject;<br \/>\n<br \/>\n<span class=\"co1\">\/\/store a reference so that it can be removed from anywhere in the application<\/span><br \/>\n<br \/>\nPopUpManager.<span class=\"me1\">centerPopUp<\/span><span class=\"br0\">&#40;<\/span>albumDetails<span class=\"br0\">&#41;<\/span>;\u00a0<br \/>\n<br \/>\nalbumDetails.<span class=\"me1\">dataVal<\/span> = itemXML;<br \/>\n<br \/>\n<span class=\"co1\">\/\/show the details inside this class<\/span><br \/>\n<br \/>\nalbumDetails.<span class=\"me1\">y<\/span> = model.<span class=\"me1\">popUpY<\/span>;<br \/>\n<br \/>\n<span class=\"co1\">\/\/position the new popup wherever we want<\/span><br \/>\n<br \/>\nalbumDetails.<span class=\"kw3\">width<\/span> = model.<span class=\"me1\">popUpWidth<\/span>;<br \/>\n<br \/>\n<span class=\"co1\">\/\/the width of this view<\/span><br \/>\n<br \/>\nalbumDetails.<span class=\"kw3\">height<\/span> = model.<span class=\"me1\">popUpHeight<\/span>;<br \/>\n<br \/>\n<span class=\"co1\">\/\/the height of this view<\/span><\/div><\/div>\n<p>\u00a0<\/p>\n<p>I have a <a href=\"http:\/\/www.wikipedia.org\/search-redirect.php?language=en&go=Go&search=singleton\">singleton<\/a> model which stores the reference to this class \u00a0so this popup can be removed from anywhere within the application by using\u00a0PopUpManager.removePopUp(model.currPopUp);<\/p>\n<p>\u00a0<\/p>\n<p>It works great and is very\u00a0convenient\u00a0way of handling views, instead of doing visibility of certain components etc. This will also improve the performance of your application since you are adding and removing classes at runtime instead of keeping them in memory and not just messing with visibility.<\/p>\n<p>\u00a0<\/p>\n<p><\/p>\n<p><!-- google_ad_section_end --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PopupManager is another utility class in Flex which i really love to use as often as i can. With big projects when you need to lay views on top of other views and things like that it really comes in handy. \u00a0 Within the Flex framework this class is also used by some of components [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-108","post","type-post","status-publish","format-standard","hentry","category-flex"],"_links":{"self":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=108"}],"version-history":[{"count":0,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/108\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}