My AS3 Window System

In the interests of building my little generative art App, I’ve decided I need some sort of window/palette system that’s robust and re-usable and looks, well, pretty cool. So I’ve made one and you can see it here.. The windows are (obviously) based on Apple’s nice little black translucent inspector windows, versions of which crop up in Aperture, Quicktime and so on. They drag from the top and bottom bars, they scale, open and close and they’re depth-managed.

There are two classes involved in all this: a WindowManager class that handles depths, focus and that very Appley drop shadow, and an Inspector class for the windows themselves. And it’s dead easy to use. Just instantiate WindowManager, add it to the stage and then tell it to create a new window with the settings you need, like so:

1
2
3
4
5
6
import tv.palmerama.gui.*;

var winManager:WindowManager = new WindowManager();
addChild(winManager);

winManager.newWindow(10, 10, 350, 200, 0.2, "My First Inspector");

That 0.2 in the newWindow() call is the fade speed in seconds, in case you were wondering. Here’s a zip of the source with the FLA as an example and the Classes.

UPDATED: They should now have the close button on the right-hand side automatically on a PC. I’m happy to say there’s no PC here to test it on, but it should work. Updated the zip too.

11 Responses to “My AS3 Window System”

-->

Comments:


  1. Where is window contents added?

  2. Good question – that’s next! I was thinking to make it easy maybe just having a rectangular windowArea mc in any content mc, then just pass that through in newWindowFromMC() or similar, omitting the width and height. Should work, I’ll have a go tonight.

  3. I did something similar and i added some basis for a compositing-aware system: feel free to use my code as well ( http://manuel.bit-fire.com/2008/09/04/compiz-like-wobbling-windows-in-as3/ ).

  4. hi

    did u get round to that. and chance of getting the updated source?

  5. Yeah I got it sorted. It now spits out events too, as you’d expect it to really. I’ll have that up mid-week.

  6. cool thanks

  7. Is this code free to use on any project?

  8. i’ve already added content to the windows with a little modifications on it, it’s a great windows system.

  9. UPDATED! (at long last…) http://www.palmerama.tv/feed/2008/10/as3-window-system-updated/

  10. DUDE! thank you sooo much!!!!!!!!! You saved my ass !! and oh, please do have a license because we’ll be soo mad if someone steal your great works! GOOD JOB!! KEEP IT UP!!! :D

  11. GREAT WORK DUDE!!!!

Say your piece...