try { succeed(); }
catch(E) { tryAgain(); }
finally { rtfm(); }
  Search
August 28, 2008   |  Login  |  
 Cool Stuff: Minimize
My Books:

available now!

available now!

 

 Print   
 Blog Roll Minimize

 Print   
 Text/HTML Minimize

I've Moved To http://www.danielwoolston.com
Please Update your bookmarks and links to the new site!
Thanks!


 Print   
Location: BlogsThe Woolston Blog    
Posted by: daniel 2/6/2008 10:58 PM

I wanted to create a modal popup for a flash app that I'm building. I'm working in ActionScript 3.0 which does not have a native popup control. If I installed the Flex framework, I'd have access to more GUI controls, but I'm really trying to keep this thing on a low footprint, so I've opted out of Flex. However, I still needed to build the popup. So this is how I did it...

var modalsprite:Sprite;


function show(object:DisplayObject, xin, yin) 
{
            modalsprite = new Sprite();
            modalsprite.graphics.beginFill(0x000000);
            modalsprite.graphics.drawRect(stage.x, stage.y, stage.width, stage.height);
            modalsprite.graphics.endFill();
            modalsprite.addChild(object);
            object.x = xin;
            object.y = yin;
            modalsprite.alpha = 0.5;
            object.alpha = 5;
            stage.addChild(modalsprite);                    
            stage.setChildIndex(modalsprite, stage.numChildren-1);
             
}


the object parameter would be the MovieClip, Buttons, Controls..etc that you want displayed on the surface of the modal background. the Xin and Yin are the corresponding coordinates for the object that you want placed.
I'm sure theres probably an easier way to do this, but I haven't found it yet.
If you have something better, by all means leave a comment for the rest of us!

 
 
Permalink |  Trackback

Your name:
Title:
Comment:
Add Comment   Cancel 
You are here: - Home
Copyright 2005 Dan Woolston
www.danwoolston.com
Terms Of Use
Privacy Statement