Fx{r} is trying to start the Fx{r} Community! Please join our group on Adobe Groups following this link: http://groups.adobe.com/groups/ab29539ab9.
Fx{r} is now on Twitter too. Follow us @ twitter.com/fx_r!
«
»

ActionScript, Flex 2, MXML

Simple modal window in ActionScript

Stelian Crisan | 29.10.07 | 3 Comments

Google Buzz

So you need a modal window and you are using Flex :) . This a small example that will open a modal window when application it’s initialized. I put the title to the modal window, but you can add also an icon.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
        layout="absolute" initialize="openModalWindow()">
 
    <mx:Script>
        <![CDATA[
            import mx.containers.Canvas;
            import mx.managers.PopUpManager;
            import mx.containers.TitleWindow;
            import mx.controls.Label;
 
            public function openModalWindow():void
            {
 
                 //define title window
                var _titleWindow:TitleWindow = new TitleWindow();
	        _titleWindow.title = "New modal window";
 
	        //define and add canvas
	        var _tmpCanvas:Canvas = new Canvas();
	        _tmpCanvas.height = 100;
	        _tmpCanvas.width = 300;
	        _titleWindow.addChild(_tmpCanvas);
 
	        //define and add label
	        var _tmpLabel:Label = new Label();
	        _tmpLabel.text = "Your modal window content.";
	       _tmpCanvas.addChild(_tmpLabel); 
 
	        //add modal window
	        PopUpManager.addPopUp(_titleWindow, this,true);
	        //center modal window
	        PopUpManager.centerPopUp(_titleWindow); 
           }
	]]>
    </mx:Script>
 
</mx:Application>

The parent display object of new pop-up window is set to this, in this case it’s the main application. To set up this new pop-up as modal window you just have to set modal parameter as true as it’s in this example:

PopUpManager.addPopUp(_titleWindow, this,true);
Share and Enjoy:
  • Twitter
  • Google Buzz
  • LinkedIn
  • Google Bookmarks
  • del.icio.us
  • Digg
  • Sphinn
  • blogmarks
  • Reddit
  • StumbleUpon
  • Facebook
  • DZone
  • FriendFeed
  • Yahoo! Buzz
  • Yahoo! Bookmarks
  • Slashdot
  • MySpace
  • Add to favorites




Tags: , ,

This post was written by Stelian Crisan

Views: 11198

related

3 Comments

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

:

:


«
»