Blog

  • PopUps in Flash & Flex

    mx.managers.PopUpManager is a utility class in Flash MX 2004, Flash 8, Flex 1.5, and Flex 2 used to create popups. A popup is classified as a component that floats above the main application. Typically, Windows, Alerts, and ComboBox drop downs are used in this fashion. Developers utilize them for creating popup dialogues like preferences, login windows, etc.

    The method createPopUp takes, usually, 3 parameters. The first is which window to pop over, the 2nd is the “thing” to create as a popup, and the 3rd is whether to make it modal or not. Modal being you have to close that popup before you can interact with any other component on the stage. Using alert() in JavaScript will generate a modal dialogue for example. Shutting down your computer on Windows XP shows a modal dialogue; you can only click one of the 4 buttons.

    Typically, the first parameter in Flash is set to _root. While not the best choice, as long as your SWF is never loaded, it’s a satisfactory choice. You are better off using your top level component, typically the one that wraps your entire application. Your main application class can provide a reference to itself for this purpose, or you can only delegate the “power of creating popups” to it, thus it can pass “this” in as the first parameter. Using _root, however, when using the centerPopUp method, it’ll utilize the whole movie to find out where the center is, thus nicely positioning the window in the center.

    _level0 isn’t so hot because if your SWF is loaded into another one, you cannot prevent the popups from “invading” your main movie via _lockroot. This is the common fix for the ComboBox component in Flash when it’s used in a SWF that is loaded. The dropdown no longer works because the PopUpManager digs his way up to find the “one true _root”.

    Seriously, I’m not justifying the use of _root, but if you’re in a rush and aren’t loading movies, it’s an acceptable choice.

    Using the component that launched the PopUpManager isn’t so hot either because centering can get really jacked up if your component you are using is itself off-centered when using centerPopUp. Granted, there are valid use cases.

    Using _root in Flex, however, isn’t such a good idea. Using it in Flash is bad enough; it’s a hardcoded reference to something. While the practice of loading Flex applications into other ones is frowned upon (by me at least), using archaic Flash references in a more Object Orienated codebase will confuse other Flex developers, and there is another way.

    Using MovieClip(mx.core.Application) instead of _root is a more “wow my code doesn’t look hardcoded even though it is” way. You and I know what _root is, but some other Flex developers might not. Additionally, the casting to MovieClip is just so the compiler will leave you alone. Perfect example of where OOP gets in the way.

    …2nd time in this blog entry I’ve been tempted to suggest using _root…

    Do not use mx.core.Application.application, that’ll crash Flex. All that is is a static getter/setter that returns _level0, but for some reason it crashes your SWF.

    In Flex 2, they actually provide a nice new method for us, popUpWindow. A conveinance method much like the Flex 1.5’s alert, which allowed you to easily create alerts with less code.

    Again, popups are not just dialogues and forms-in-your-face, they can be for component GUI controls, as well. Just the other day, I created the popup slider that you have in Photoshop and Fireworks for adjusting alpha values; the actual slider is a popup. On the other end of the spectrum, entire mini-applications can be used as popups as well. They are draggable when using containers like Panel & TitleWindow if you don’t make them modal.

  • Adobe Gets in the Labs Mix

    There is a new Adobe Beta called Adobe Lightroom at the labs. It’s nice to see Adobe so quickly adapt adopt the Macromedia lab mindset.

    The front-page picture is really nice and soothing, but I get nervous when that giant eye stares at me at 1:00am…

  • ColdFusion Contractor Position: Atlanta, GA, USA

    Our company is working toward a deadline for a client and we are in need of a Coldfusion contractor that is familiar with:

    • OOP, CFCs, SQL Server
    • Stored procedures, Flash Forms/Flash Remoting a plus
    • Must be available to work on-site (Atlanta/Chamblee area)

    If your skill set matches or you know someone who does have these qualifications, we could use someone immediately.

    Thanks for your time,

    Dave Jones
    thoughtbox
    p: 404-271-9123

  • FlickrMobile: A Flash Lite 2 Applicatio

    *** Update 4.25.2006: Provided a Flash Player 6 version for PSP.

    *** Update: Yes, I used FAME (Flashout + ASDT + MTASC + Eclipse) to build this.

    Preface

    As has been reported by Scott F. and Scott J., the Flash Lite 2 Update for Flash Professional 8 has been posted, allowing Flash Developers to create content for the Flash Lite 2 player which has been on sale for only a short while. Since the update gives you the SDK, all the documentation you need to get started creating Flash Lite 2 applications, and the emulator to preview your content in Flash 8 Professional, I figured I’d show you an example of what can be done.

    FlickrMobile – A Flash Lite 2 Application

    FlickrMobile is a small app I put together showcasing my favorite apps for phones; using Flash as the front-end to access server-side content. All of the web API’s that have been appearing are just ripe for harvesting, and Flickr is one of the best.

    Now, you can email/multmedia message your pictures to Flickr from your phone AND view them from your phone… how cool is that!? I am constantly emptying my memory card on my phone where my images are stored, and my other camera that takes better pictures already has all of its images up at Flickr. So, even if I am not posting anything, it’s nice to show friends some images I have no matter where I am (one of these days I’ll get a laptop).

    TOP

    Back-end

    I used phpFlickr on the back-end with AMFPHP. Since Flash Lite 2 doesn’t support Flash Remoting (found this out in the middle of development, hehe), I just used a simple PHP FrontController pattern to take LoadVars commands, and spit back XML. Easy stuff. I love PHP.

    TOP

    Flash Lite 2 Components

    If you are like me, you thought using Flash 4 syntax was a joke. I swore I’d never do Flash Lite development until I got AS2. Macromedia over delivered, giving me other features I didn’t even think about using on a phone.

    One key thing missing, though, were components. It is implied you should use the Flash Lite 1.1 ones, but I’d rather be thrown in a burlap sack tied shut with a dog, snake, and a monkey all inside with me as the sack is thrown into a deep river vs. using those things for “application development”. (context: the Romans did that, George Carlin told me so)

    Richard Leggett felt… somewhat the same way. So, we made a lighter version of the v2 components to work in Flash since the v2 ones that come with MX 2004 & 8 do not work on phones; they are too bulky.

    Unfortunately, they were also a testing ground for seeing what Flash Lite 2 can do, as well as my failed attempt at doing deferred instantiation like Flex does, so they really aren’t mature enough for mass developer usage. However, they are something, and allowed me to create this application as a proof of concept.

    What did it prove? Flash Lite 2 is f’ing sweet. J2ME just got served.

    TOP

    Example

    Once connected, use left and right keys to change images.

    TOP

    Source Code

    FlickrMobile – ZIP

    Tested and works on my Nokia 6680.

    Known Issues:

    • Slow – Flickr’s sometimes extremely slow and unresponsive and my Cingular MediaNet is dog slow.
    • Cannot press next and back quickly; if you do, it’ll wait to download the images in order, before downloading the next, thus causing a long wait to see the image you selected. Known bug in Flash Lite 2.
    • Some Flickr images from their static server do not load. Unknown cause.

    To use, just install Flash Lite 2 on your phone, copy the compiled SWF to your phone (included in ZIP), and run from Flash. At the connect screen type in your Flickr name in the field, and click “Connect”.

    Creative Commons License
    This work is licensed under a Creative Commons Attribution 2.5 License.

    TOP