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
There is an error in Session 1 of Hello! Flex 4. This error got introduced during typesetting. I have been raked over the coals for this in a one-star review of the book here.

The short version is you need to change the code in Session 1 to this:

<?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>

For the long version, this is the reply that I posted to that review…

Hi Steven,

I’m Peter Armstrong, the author of Hello! Flex 4.

You are correct that on page 6 of the book, the text is:

<s:Label="Hello! Flex 4" >
fontSize="128"/>

This is obviously a bug. The corrected text should be:

<s:Label text="Hello! Flex 4" >
fontSize="128"/>

I am very sorry that I missed this error.

Now, there’s actually an interesting reason why this happened…

The initial completed manuscript of Hello! Flex 4 was written against Flex 4 Beta 1. In Beta 1 of Flex 4, you did not write s:Label, you wrote s:SimpleText.

I just dug up my completed manuscript, and here’s what the code sample was:

<?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/halo">
<s:SimpleText text="Hello! Flex 4" >
fontSize="128"/>
</s:Application>

Note that it is correct. Besides pasting all the code in from the IDE into the manuscript, I also went the other way during the development editing process, pasting code from the manuscript back into Flash Builder. Everything worked.

Now, a few days before Hello! Flex 4 was going to press, Adobe delayed the ship date of Flex 4 from Q4 2009 to Q1 2010. They also released Beta 2 of Flex 4.

In Beta 2, Adobe changed s:SimpleText to s:Label, thus breaking the entire book!

Now, the book had already gone through all the editing and had been typeset. But, we obviously couldn’t ship the book like that. So, my instructions were to go through it and change all s:SimpleText to s:Label. This was done correctly everywhere in the book, except for in this one example in which case the text attribute got deleted.

Unfortunately, this happened to be the first example in the book!

I can assure you that I have compiled and run the code many times, during Flex 4 Beta 1, Beta 2 and (after the book was released) with Flex 4 Final.

So, to be clear, the full source code of this example (with Flex 4 Beta 2) should have been:

<?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/halo">
<s:Label text="Hello! Flex 4" >
fontSize="128"/>
</s:Application>

This is exactly what you say you needed to change the text to be. So, you’re completely correct.

However, if you had published that in a Flex 4 book you wrote, you would also be wrong!

See, there’s one more wrinkle… With Flex 4 Final, the full source code of this example should have been:

<?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>

Spot the difference? The library://ns.adobe.com/flex/halo namespace got renamed to library://ns.adobe.com/flex/mx. This namespace change was made after Hello! Flex 4 went to press.

(This is my second book about Flex, and the joys of writing a technical book never get old!)

So, if you are using the final version of Flex 4 with the book examples, remember, always replace:

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

with

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

There are a couple of other minor changes, which are fully explained at the following blog post I made yesterday:
http://www.peterarmstrong.com/?p=169

This post has a link to the updated source code which works with Flex 4 Final.

If you do give the book another chance, what I highly recommend doing is downloading the updated code and using that, instead of typing in the code from the book.

Thanks,
Peter Armstrong