In a previous post I presented a library of sparkline implementations for Flex 3. I have finally gotten round to updating it for Flex 4. The new source code, documentation and pre-compiled swf (namespace:
http://www.scottlogic.com/sparkline) can be obtained from here. As before, the components are being made available under the GNU General Public License.
As you can see, the versions appear identical:
Updating to Flex 4
For those of you interested in some of the changes required to migrate code from Flex 3 to Flex 4, here follow some of the details required to update this particular code.
The main change was due to Flex 4 essentially deprecating the
StyleManager class and its static methods in order to provide mechanisms allowing modules to have independent style declarations. At the forefront of this change is the new
IStyleManager2 interface, an instance of which can be obtained from the static
getStyleManager method on
StyleManager or, preferably, the
styleManager property of
UIComponent. In practice, using the
Sparkline class as an example, this means changing from the static Flex 3 style declaration approach:
You will also see that as of Flex 4, getting style declarations now requires a fully qualified class name rather than just the name of the class, e.g.
com.scottlogic.sparkline.Sparkline rather than
Sparkline. As before, this change is required due to the underlying shift in the approach used for style management by the framework in order to support independence between modules.
The other update required was due to the changed
IStroke interfaces. In particular, the
begin method on
IFill takes an additional
targetOrigin argument of type
Point that specifies intended origin of the shape drawing. Similarly,
apply method now takes two additional arguments,
targetOrigin, to provide the same drawing manipulation/restriction as
IFill. Fortunately, the SDK team appear to have anticipated the potential complications and frustrations arising from these changes and have implemented them so that specifying a
null value for the additional arguments results in identical behaviour to that which would have occurred in the Flex 3 code.
UPDATE 13/09/2013: I have added the codebase to GitHub.