Avg. Rating 3.3

Problem

I am designing a homepage that has a pop-up window with tabs that display several topics such as "about", "faq", etc. I only want the popwindow to show the first time someone comes to the homepage.

Solution

You need to use "creationComplete" event of Flex Application Container to achieve the above.

Detailed explanation

Code for doing it is shown below. Here i am calling " creationComplete" event of Application Container which will only be called when application is loaded i.e only once every time application loads.

On " creationComplete" event i am calling " showPopUpWindow()" function which is doing the work of creating the pop using PopManager class. Replace your pop window class in place of "YourPopUp" class which i am using in below code and  things should work fine for you.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"  
       xmlns:s="library://ns.adobe.com/flex/spark"  
       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
        creationComplete="showPopUpWindow()">
  <fx:Declarations>
   <!-- Place non-visual elements (e.g., services, value objects) here -->
  </fx:Declarations>
  
  <fx:Script>
   <![CDATA[
    import mx.managers.PopUpManager;
    
    var yourPopUp:YourPopUp;
    

    /* Creating pop up window here */


    public function showPopUpWindow():void{
      
        var yourPopUp = new YourPopUp(); // this is your pop up class
        yourPopUp= PopUpManager.createPopUp(this, YourPopUp, true) as YourPopUp;
        PopUpManager.centerPopUp(yourPopUp);
      
    }


    /* Call this function for closing the pop up window */


    public function closePopUp():void{
      
        PopUpManager.removePopUp(yourPopUp);
  
    }
    
    
   ]]>
  </fx:Script>
</s:Application>


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes