The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

peterarmstrong (94) [Avatar] Offline
#1
Hello! Flex 4 was going to ship last year, based on Flex 4 Beta 1. However, Adobe delayed the Flex 4 Final release and instead released a Beta 2 version of Flex 4.

This beta version broke the book. Specifically, they changed s:SimpleText to s:Label.

So, I spent a couple days madly modifying the fully typeset version of the book to update it to Flex 4 Beta 2.

We then had to make a decision (i.e. a guess) about whether there would be any more breaking changes in Flex 4 Final, or whether we could release the book based on Beta 2. We decided to ship the book, since the reasoning was that any release SDK changes would be minor.

Now that the Flex 4 Final SDK is out, I still think we made the right decision.

However, there are some changes which means that certain parts of the book need an update. This post will go over the big picture changes. To get the updated code for Hello! Flex 4, which works with Flex 4 Final, click here. (If you are using the released version of Flash Builder 4, you want this code!)

1. A namespace change

First, the big, capricious, annoying change:

xmlns:mx="library://ns.adobe.com/flex/halo“

is now

xmlns:mx="library://ns.adobe.com/flex/mx“

Sigh.

This means that I have a namespace bug in essentially all the MXML files in the book. It’s minor, but it may trip up newcomers.

Note that this also affects the CSS:

@namespace mx "library://ns.adobe.com/flex/halo";

is now

@namespace mx "library://ns.adobe.com/flex/mx";

2. Two Way Data Binding and Model Objects Has Been Fixed

This is a Good Thing, but it means that the part of Session 3 that warns about two-way binding and model objects (session03/src/TwoWayBindingClobbersModel.mxml) is now outdated. I’m happy about this though, and am glad that was a bug and not a “feature”!

3. Two Way Data Binding, When Thrown Around All Over The Place, Can Crash the Flash Player

In Session 12 I threw around a bunch of two-way data bindings to the same variable. No, I’m not sure why I did this, but it seemed fun at the time. Turns out that with the release version of the Flex 4 SDK this now crashes the latest Flash Player (10.0.45.2). I’m not sure if this is a bug or feature. To fix the code in Session 12, all you do is change all but one of the two-way data bindings (@{_bread}) to the _bread variable to one-way data bindings ({_bread}). (The one-way data bindings have no @ sign.)

4. I Have a Typesetting Bug is Session 1.

There is another post entirely about this bug. The short version is that it should look like this (note the text=):

<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:Label text="Hello! Flex 4"
fontSize="128"/>
</s:Application>

5. I Have a Horribly Sloppy Data Binding Bug in Session 14c

As an astute reader (hi Dusan!) points out, the code in Session 14c has a data binding bug. This bug existed in both Flex 4 Beta 2 and Flex 4 Final, since it’s my bug!

Specifically, I was binding to a getter which was never being triggered, so the Player 1 Turn / Player 2 Turn label would never get displayed. You can actually see this bug in a screenshot on page 84, since there’s no label showing there beside the New Game button! Argh.

Anyway, in the revised code for the book, I fix this by just making the BoardDisplay class expose a board variable (which was called _board in the book), and then I just bind to that.

I have no idea how I missed this.

6. SkinnableContainer now uses a BasicLayout by default, so the screenshot on Page 97 is a bit outdated.

That’s it!

I’ve now tested all 26 workshop sessions and the chapter 7 SocialStalkr application with Flex 4 Final. Other than my one very sloppy bug and the annoying namespace change, everything is pretty good.

If you read the book, thanks! If you spot any more bugs not shown here, please email me (peter@ruboss.com).

Thanks for reading!

We're updating the code zip file soon...