Flex 2 Training From the Source sample chapters available on Adobe’s DevNet Site

In browsing the latest Developer Center Update email, I noticed that they have chosen to include 4 chapters from our Flex  Book on their site.   It looks like they have put the pdf’s and files for Chapters 11 (DataGrids), 16 (Styles and Skins), 20 (FDS Data Push) and 21 (FDS Data Services). 

One thing any readers on DevNet should be aware, is there is an issue with one block of code in chapter 11, running in the updated Flex Builder 2.0.1.  On page 275, when creating the inline item renderer for a DataGrid cell, you need to modify it slightly for it to compile in Flex 2.0.1.

The book has you right the code like this:

<mx:DataGridColumn editable="false">
 <mx:itemRenderer>
  <mx:Component>
   <mx:VBox>
    <mx:Button
     label="Remove"
     click="outerDocument.removeItem(valueObjects.ShoppingCartItem(data));"/>
   </mx:VBox>
  </mx:Component>
 </mx:itemRenderer>
</mx:DataGridColumn>

 To get it to compile with the updated FlexBuilder, you need to modify it like this:

<mx:DataGridColumn editable="false">
 <mx:itemRenderer>
  <mx:Component>
   <mx:Script>
    import valueObjects.ShoppingCartItem;
   </mx:Script>
   <mx:VBox>
    <mx:Button
     label="Remove"
     click="outerDocument.removeItem(valueObjects.ShoppingCartItem(data));"/>
   </mx:VBox>
  </mx:Component>
 </mx:itemRenderer>
</mx:DataGridColumn>

We are still actively trying to get the publisher to put up an errata site for the book, but this is the only issue with the book code that I have heard about from our readers.

Enjoy the sample chapters!

10 Comments

    Carlos –

    While both elements in the Category() function (also called a constructor) are prefaced with “this.” the reality is that it was only required on one of the two (the catName property). In cases where the argument to the function is the same as the property name, you must preface references to the property with “this.” to differentiate whether you are refering to the argument passed into the function, or the property of the class. In the case of catID, the classes property is called “catID”, but the functions argument is “id” so the “this” prefix is optional. It was included as a stylistic choice, but the constructor would work just as well if it read

    public function Category (id:int, catName:String) {
         catID=id;
         this.catName=catName;
    }
    

    If the “catName” argument were called something else, then the “this” keyword wouldnt be required for either, like this:

    public function Category (id:int, cat:String) {
         catID=id;
         catName=cat;
    }
    

    Hope this helps…

    • by Jeff Tapper
    • 12:02 am, February 15, 2007
    • Reply

    Jeff:

    I wrote to Peachpit three days ago asking about where to see errata; they replied saying that they were working on it and something should be available in about a week.

    They also said to report any errors I might be aware of. I have seen what I thought were coding errors, but later turned out to be errors I made when doing the lessons in the book, and, since I am very new at this, I am reluctant to report anything directly to Peachpit. But here is something that you might want to look at:

    Page 169 in 3, the paragraph after the function ‘Category()’ reads: “…. in this case, only the catName property had to use the this prefix because ….”.

    But in the constructor, both properties are preceded by ‘this.’. I find this confusing: am I missing something, or should it read differently?

    • by Carlos Corredor
    • 12:02 am, February 15, 2007
    • Reply

    Hello, Jeff –

    From what I have seen so far, the book always says exactly what to do, no more, no less; it’s just that sometimes one tends to read more into something than necessary.

    Got it! Thank you very much for the clarification.

    Simultaneously with this, I have added a comment to the thread titled “INTERNATIONALIZING FLEX 2 APPS PT 2”. I have been having a tough time getting a function defined in the main MXML application to also work in Custom Components in the same project. In this new post, I describe the various things I have tried, with no success.

    I would appreciate your looking at this to see if you want to help. I am even willing to pay for solving my problem, as long as the fee is not tailored to a big enterprise – I’m just a little guy, but have a project coming up for a small men’s fashion site, that will be in three languages to start with, and may end up expanding to six or more languages.

    Thanks again,

    Carlos

    • by Carlos Corredor
    • 12:02 am, February 17, 2007
    • Reply

    Jeff –

    You probably want to look into what might be an erratum in the TFS code. I came across this while working on Lesson 8 – it may be a path issue, but I haven’t been able to figure it out:

    When I run the Ecomm app, the horizontal display of categories does not show the images, but the missing image icons. So I ran the completed project; same result, with both the images in the categories display and the food items vertical display.

    If you can run the project without getting that error, I would appreciate some kind of hint as to what I may be doing wrong.

    Regards,

    Carlos

    • by Carlos Corredor
    • 12:02 am, February 24, 2007
    • Reply

    Jeff –

    You probably want to look into what might be an erratum in the TFS code. I came across this while working on Lesson 8 – it may be a path issue, but I haven’t been able to figure it out:

    When I run the Ecomm app, the horizontal display of categories does not show the images, but the missing image icons. So I ran the completed project; same result, with both the images in the categories display and the food items vertical display.

    If you can run the project without getting that error, I would appreciate some kind of hint as to what I may be doing wrong.

    Regards,

    Carlos

    • by Carlos Corredor
    • 12:02 am, February 24, 2007
    • Reply

    Wayne –

    What version of Flex are you running? 2.0.0, 2.0.1 or 3 Beta? The neccessary syntax is a bit different depending on which one you are using

    • by Jeff Tapper
    • 12:07 am, July 26, 2007
    • Reply

    Great book. I’ve recommended it to my company. I’m still trying to get the itemrenderer to happen. But with the revision to add mx:script I’m now getting a parse error. Any thoughts?

    • by wayne
    • 12:07 am, July 26, 2007
    • Reply

    hello, i’m try this
    click=”import valueObjects.ShoppingCartItem;
    outerDocument.removeItem(valueObjects.ShoppingCartItem(data));”
    and works in flex builder 3 b2… thanks anyway

    • by A visitor
    • 12:10 am, October 15, 2007
    • Reply

    hi, i have the problem :” parse error at <mx:script>”. i’m use flex builder 3 b2, some idea thanks.

    • by A visitor
    • 12:10 am, October 15, 2007
    • Reply

    This worked for me!
    click="import valueObjects.ShoppingCartItem;
    outerDocument.removeItem(valueObjects.ShoppingCartItem(data));"

    • by Steven
    • 2:10 pm, October 23, 2008
    • Reply

Leave a Reply