I’ve gone back and forth over this, trying to decide how complex to make this blog entry. The truth is, writing components in Flex 2 is pretty easy. What I was deciding between is whether or not to start with a component that does not use skins and then build up to adding skins.
I decided that skins are pretty easy (for us non-artists) so we’ll make a component, “from scratch” skins and all.
You can see a running example by clicking here
. Some of the gauges are connected, meaning that changing values in one changes others. The ones labeled “interactive” respond to the mouse. Yours to explore.
One of the benefits of the Flash Player technology is being able to write applications in the manner that best suits you. For example, you can use Flash 8 to develop high-impact animations or use Flex to build compelling business applications.
What is even better is being able to combine them together. It turns out that creating an animiation in Flash and incorporating it into a Flex application is not uncommon. And because both Flex and Flash are language driven via ActionScript, the Flex application could control the Flash animiation or vice-versa.
Doing this with Flash 8, Flash MX 2004 or Flash MX and Flex 1.5 was relatively easy. But that is not the case with Flex 2 and Flash Player 9. I’ll show how to do this and I hope you see that this is in fact, a better way to do it.
As you may know, a Flex 2 SWF requires Flash Player 9. That’s because Flex 2 uses ActionScript version 3 (AS3) and Flash Player 9 was developed (from the ground up, I’m told) to use ActionScript 3. ActionScript 3 with its stronger data typing and object-oriented structure provides a better platform for a higher performing Flash Player.
But as with all versions of the Flash Player, Flash Player 9 is backward-compatible. That is, it will run SWFs built for earlier Flash Player versions. But this happens differently than before. When the Flash Player 9 loads a SWF that uses ActionScript 2 (or less), it creates a virtual machine – a self-contained area which is loaded with the logic to run ActionScript 2 SWFs. We call this an AVM. When Flash Player 9 has loaded a Flex 2 SWF which then requests to load an AS2 SWF, that SWF is loaded into its own AVM. Thus the two SWFs run in different areas of the Flash Player. Different and isolated areas.
What this means is that your Flex 2 application cannot address the AS2 SWF and reach inside and reference its functions, variables, and timeline. Likewise, the AS2 SWF cannot get at anything in the Flex 2 application simply by referencing it.
MAX 2006 – Adobe User Conference
October 23-26, 2006
MAX 2006, the Adobe user conference, will be held at the Venetian Resort Hotel located in Las Vegas, Nevada. There you can learn new skills, explore emerging technologies, connect with peers, and move beyond the boundaries of what you believe is possible. The conference will be made up of over 100 different hands-on and workshop sessions presented by Adobe experts and other industry leaders on best practices and coming technologies. During the event you can exchange ideas with designers, developers, and other community members at networking sessions and “birds-of-a-feather” sessions while exploring Adobe technology at a variety of events and venues, including all-day pre-conference training sessions, a Test Drive and Product Support Lab, and Sneak Peek sessions. Sign up today and get $200 off registration. Click here to register now www.adobemax06.com. Or to find out more details regarding the conference click here www.adobe.com/events/max