Blog

  • Flash Content in Flex Preso

    I did a Connect presentation for the Arizona Flash Platform User Group Wednesday evening about using Flash content in Flex. If you didn’t get to attend my 360Flex presentation in San Jose, California back in March, this is a lot of what I covered there. I’ve added some updates based on my 4 months of working. I didn’t get to talk about the Flex component kit for Flash as in depth as I wanted because my copy of Flash CS3 is giving me grief on my PC with licensing. It’s about 1 hour and 20 minutes long and you can skip ahead through the stuff you already know.

    Flash Content in Flex

  • Making a Cooler Preloader in Flex: Part 1 of 3

    Preloader Preview

    Preface

    Preloaders in Flex are not like preloaders in Flash. Gone are the days of the 1 liner:

    if ( _framesloaded < _totalframes ) gotoAndPlay ( 1 );

    We now have base classes and setter properties. While you may have to write a class and then set that class on your Application’s preloader property, it’s really pretty easy once you do it more than once. This tutorial will show you how to build a preloader in Flex using a Flash built animation.

    Introduction

    Flex’ built in preloader is pretty sweet. It auto-adjusts for your application’s color to stand out, it handles all aspects of preloading. This includes remote shared libraries, fonts, and even deferred classes used in modules. Finally, it deals with the initialization of your Flex application which can possibly take longer than a few milliseconds.

    If you are building branded applications, every little detail counts in enforcing your brand identity upon your user. You want to remind them the positive experience they are having was brought to them by you. Nothing is more important than a first impression, and the first thing people see in a Flex application is the preloader. It is important that you spend adequate time on making it look good and consistent.

    To make a custom preloader for Flex, you have to do 2 steps:

    1. Write a class that extends DownloadProgressBar
    2. Set the preloader property on your Application class to your preloader class.

    No witty 3 step process here.

    The purpose of extending DownloadProgressBar is to handle the various things that happen in the life cycle of preloading (yes, we have life cycles now, not just downloading of bits). You do not have to handle anything save the FlexEvent.INIT_COMPLETE. You could for example put some dots who are ridin’ spinnaz and that’s your preloader.

    …or, you could handle all events, and duplicate the Flex one with a different design showing the download & initialization progress.

    The steps for making a custom Flash Preloader for your Flex app are as follows:

    1. Make a 100 frame MovieClip. TextField optional (as is everything).
    2. Give MovieClip linkage ID with no class name.
    3. Compile your SWF (“Test Movie”)
    4. Write your own Preloader class in Flex Builder which uses your Flash MovieClip.
    5. Set the Appliction.mxml preloader property to your custom class.

    Making Your Flash Symbol

    In Flash, you make a MovieClip that is 100 frames long. This will be the preloading part of your preloader, the MovieClip that shows the progress of the SWF downloading. Notice I have both a 100 frame animation as well as a dynamic TextField. The TextField will have the percentage numbers (i.e. “73%”) put into it dynamically.

    Notice, also that the TextField has an instance name. This is so I can target it with code. Keep in mind, even though we are giving the TextField an instance name, we’ll be targeting it with code in Flex. We won’t be writing any code in Flash.

    Finally, I wrap my preloader in a MovieClip because I want the preloader to fade out when it’s done.

    I make sure to give the preloader an instance name so I can “dot dot down” to the preloader through the animation. Dot dot down is Flash slang for using dot syntax to walk down the display tree to target a MovieClip you want to interact with via code. In our case, it could be:

    _root.my_clip.preloader.amount_txt.text = "70%";

    Omg, I used _root, lol, l@mz03, me fired.

    Finally, you export your Symbol with a linkage ID. Exporting as Flash 8, AS2, you just fill in the linkage ID class. Don’t export as Flash 9, AS3. If we did that, we might as well write the class for the preloader , and that’s just too much work, and too much added file-size for a class that’s supposed to be simple and most of all lightweight. If you are using Flash CS3, just change your publish settings to Flash 8, AS2 or AS1.

    Flex will look for this linkage ID name when you are embedding the MovieClip. Now compile your SWF and your done.

    Custom Preloader Class

    You then write your own Preloader class. Have it extend mx.preloaders.DownloadProgressBar. There are multiple ways to embed Flash content. For our purposes, we’ll embed to a class property.

    If you look at the Preloader’s setter function, you’ll see we get a Sprite (1 frame MovieClip) that emits all the preloading events we’ll care about. In this case download progress, when the SWF has finished downloading, when the SWF starts to initialize classes, and when initialization is complete.

    Our download progress & SWF download done functions will dig down into the Flash MovieClip, and show download progress in both the text field, as well as making the preload MovieClip symbol animate via gotoAndStop based on the download percentage. Since download percentages are 100%, it makes it pretty easy to figure out what frame to go to.

    The initialization ones just show “Initializing…” in the TextField.

    Unlike most Flex preloaders, we want ours to animate when done, and only THEN actually launch into our Flex application. You can accomplish this by not dispatching the complete event. Dispatching this let’s the Flex application know the preloader is done. In our case, we want to wait till the Flash animation is done before doing so. We add a framescript ( a function called when the Playhead reaches a frame) to frame 21. When the animation is done, it’ll hit this frame, call our preloader class’ function. This will stop the animation and dispatch the event, letting the Flex application know we’re ready.

    Conclusion

    That’s it! Keep in mind it’s hard to test these things locally on your box. In Flash, we have the bandwidth profiler, but there is no such thing in Flex. You can either use network throttlers, like Charles. Alternatively you can upload the files to your site, install the Firefox Web Developer Toolbar, and choose disable cache.

    In the next part, we’ll be taking advantage of Flex as a statefull client, and getting all the data you need. This takes time, so we need a cool way to show this to user as well as making it fail gracefully.

    Flash Preloader in FlexExample | Source | ZIP

  • Jumpeye V3 Components for Flash

    Raul Popa emailed me last month asking for a fair review of their Jumpeye V3 components for Flash 8 & Flash CS3. I get a lot of product & book review requests and ignore all the ones that sound boring. This one sounded interesting, although, mis-placed since until recently, my AS2 work had all but died now that I do full-time Flex. I mentioned I could either use them on a project and write a war story review, or just open up the code base and do a code review. He was cool with that but mentioned I couldn’t crack them easily; I think he interpreted me trying to hack them which wasn’t my intention. I just wrongly assumed that if you give out components, you also get the source code & FLA’s. Ah, to be young and naive…

    Anyway, cleaning out my inbox yesterday morning while waiting for her majesty’s car to be lizz-ubed, I came across his email starred and wrote a follow up. At my current gig, there is a client who needs yet another video player. I had refused to get involved in any large scale Flash development projects since in my opinion there was a lot of Flex work to be done, and the current Flashdevs could handle it. Now that I was getting dragged in, I was going to do it right. Keep in mind, we’re doing our stuff on the video player end in AS2 because of Flash Player 8’s penetration numbers far exceed Flash Player 9, and AS2 compiles to Flash Player 7 & Flash Player 6 as well, so it’s a no-brainer.

    First order of business was getting team agreement on a component set to use. Those mentioned were mCom (pre-Flash CS3), Bit Components (aka the Beamjive), and my Flash Lite Shuriken ones. Upon coming upon his email, I let Raul know that I may be able to use them in a project. After sending, I opened them up, and tested a few out. They worked, and seemed to be aimed at IDE integration and XML configuration. As a developer of Flash components, the first thing I did was look for source code, but found none. I asked in another email, and Raul replied that you do not get the source code.

    I responded saying that you need to change your business strategy; people like me need source code to debug, build upon, and customize. After a few back and forth emails, I learned I was not his target market. He cited survey responses that I mostly agreed with and could corroborate. I got my start in this industry by building simple Flash components back in Flash MX . They were targeted at designers who wanted to drag and drop things on the stage from the library. These components would then be customizable by the Property Inspector (more challenging than it sounds to support that for someone like me who didn’t know OOP very well back then). Finally, all the components were skinnable via the graphic symbols in the library.

    To this day, there is a lot of people who have very successful careers (even in 2002 when the market blew) by using pre-built components that have configurable properties. Furthermore, with the explosion of server-side API’s the last few years, you can make some sophisticated solutions for clients in Flash without having to know a lot of programming. That’s powerful, and a fun market to develop for since most of the customer (FlashDevs) feedback is very excited and ecstatic. As users, their feature requests for the component IDE integrations aren’t all that complicated. It’s just a matter of finding time.

    So, upon reading Pixelfumes’ review, I totally got it. Furthermore, it reinforces where I wanted to take a lot of my ideas. Basically, you create mini-applications as components. A button is one thing, an mp3 player is another. Jumpeye isn’t just making Flash components, they’re making mini-RIA components as well like their XML Slideshow for example. Yes, you could use component sets to build these things, but why? Why not just use a component instead, and build the branding around it? Makes perfect sense to me for small scale contracting, and larger scale agency work. I could even see it in small scale RIA development if your deadlines are short. They’ve also done the little things that all Flash Devs do; modify things on a common component they’ve always wanted, but didn’t get out the box. A horizontal Accordion for example. I cannot count how many times I’ve seen emails asking for that on Flash & Flex email lists.

    Bottom line, I think for Flash Devs working with designers, or even just designers, this set was made for them. It has skinning as a forefront in their creation, and integrates in the normal ways you expect a Flash component to integrate with the Flash IDE (property inspector, helpful errors in output window, drag and drop to stage and “they just work”). Haven’t read the docs since I only read docs when I have problems, but the amount of examples seems to reduce the need. Furthermore, the pricing is apparently a direct result of the support costs, something I’ve heard in the past as a deterrent to doing commercial component sets. Meaning, it sounds like their support structure will counter what has plauged a lot of the other component sets in the past.

    Will I use them? No, I don’t do that type of work anymore. I do see a lot of people, however, really getting excited about this set? Yeah, definitely. If you are a designer or Flash Dev doing small scale RIA work, and/or doing heavy design integration, check ’em out. If you are a Flex dev, the AS2 versions aren’t going to work for you, but will give you some design & customization ideas for the Flex 2 SDK ones. Furthermore, if the AS3 ones are easily wrapped in a UIComponent, they may have a future in integrating.

    Yes, they are working on an AS3 set, and yes, if you buy now, you’ll get those without having to purchase them separately.

    Check ’em out.

  • iPhone as Mobile Platform Mole

    This article was making the rounds last week. While sensationalistic, I think it’s justified and a well-written article. Definitely food for thought. The counter-point to this article is that Flash may be in our iPhone’s future. As we all know, things currently suck.

    The iPhone Threat to Adobe, Microsoft, Sun, Real, BREW, Symbian

    Via Steven Sacks.