What is the Difference between a custom Component and an ItemRenderer?

I've been working with D for a few months as a personal mentoring client. We chat either via e-mail or Skype and I help him with his personal growth as a programmer. He asked me this question recently on itemRenderers and custom Flex components which made me think, so I'm turning it into a post:

What is the difference between a custom component and an item renderer? Are they or can they be the same thing??

In general terms, an itemRenderer is a custom component. But, not all custom components can be used as itemRenderers.

An itemRenderer component should implement IDataRenderer interface. This gives the component a data property which the itemRenderer "generator" uses to pass in the data to be displayed.

If used in list based classes, an itemRenderer should probably also implement IDropInListItemRenderer interface and/or IListItemRenderer. The IDropInListItemRenderer interface adds the listData property, which gives you custom access to list stuff. In the Flextras AutoCompleteComboBox itemRenderers get passed a custom subclass of listData that includes the type ahead text and is used for highlighting purposes.

The IListItemRenderer is basically a bunch of UIComponent stuff with the addition of the IDataRenderer. Unless you're doing fringe Flex Development, all your itemRenderers will extend UIComponent in some manner.

These interfaces are implemented by most of the Flex controls, such as radio buttons, checkboxes, and ComboBoxes.

To give a more accurate answer, the itemRenderer property is a class factory that creates instances of the specified custom component. A factory is just a class that creates other classes, and most itemRenderers in Flex are instances of the ClassFactory. This is masked a bit in MXML, where you specify the itemRenderer value as an absolute class path, not an instance of the ClassFactory.

I couldn't decide whether to post this to my personal blog or the Flextras blog. I thought about putting it on the Flextras and posting a link from here, but that would be cheesy, right? I posted here because this blog is in the aggregators and more people read it. I do like fielding questions from the audience, so feel free to ask them or stop by a Flextras Friday Lunch session and ask me in person.

If you're really inspired to show you support check out The Flex Show's sponsorship drive, which ends in a few days.

How do I Flex lines drawn with lineTo selectable?

This comes in from a reader:

I need to make a application which helps in making a Data Flow Diagram, everything is done in it but I need to make lines selectable on that diagram. That means once a line drawn can be re sized. I am using Graphics.lineTo() functions to draw a line but once line drawn can never be selected.

It sounds like a cool app. I don't have an answer this time, though, and as such my answer might be off.

From what I understood, you need a sprite for something to be selectable. Graphics.lineTo does not create one as best I understand it.

He'll have to put the line in some specific container to make it selectable, perhaps a highly customized Button or a mod of the VRule or HRule classes.

Next Day Update I got a solution from the reader. He wrapped up his 'line' in a UIComponent and was able to get everything working great / as expected.

I do like answering questions, even though I tend to get real busy these days trying to make Flextras work as a business. You can ask me your question here, or stop by a Flextras Friday Lunch session and ask me in person. If you're really inspired to show you support check out The Flex Show's sponsorship drive.

Seven Things Meme

I saw this on a friend's Live Journal and thought it was interesting enough to partake myself:

A. List seven habits/quirks/facts about yourself. B. Tag seven people to do the same. C. Do not tag the person who tagged you or say that you tag "whoever wants to do it."

  • There are about a dozen cabbage patch kids, 50 webkins, and hundreds of other assorted animals throughout my house. I don't have kids.
  • I can solve the Rubik's Cube, most of the time in under five minutes.
  • I spent >$200 for this ergonomically correct keyboard drawer, and >$600 for this ergonomically correct chair, but still have a crappy desk which I believe prevents me from working in an ergonomically correct way. I blame the constant dull ache on the right side of my jaw to ergonomic issues.
  • I have been Pepsi / cola free since the Sunday after last Thanksgiving. It has affected my ability to work in an extremely positive way; instead of putting in 4-6 hour days I can put in 10-12 hour days. I'm more aware and more efficient and I can get things done. I did go out to Wendy's with the wife and have a Frosty Float w/ Root Beer a few days ago. Most of the time I drink water and various juices. I want to start juicing my own fruits and vegetables.
  • The first loaf of bread I ever made came out very salty, I think I mistook teaspoons and tablespoons in the measurements. I would be less liable to do that if there was a consistent abbreviation for them. I think I'm learning that 'b' means tablespoons and no 'b' means teaspoons.
  • I did not pick up the phone call two--now three--times this morning. I woke up late and am still shaking the dust off.
  • Coming up with seven items was harder than I thought, but I'm not going to tag anyone.

2009 Holiday Letter Plus a Look Forward

This is a slightly modified version of the Holiday letter that T and I sent out. If you didn't get one, but thought you should have, let me know. T wrote most of this because I Was too lazy.

The year has, indeed, been busy. Most of the year was consumed with wedding stuff. In fact, if you look closely, you'll still find things that need to be put away; the twinkle lights from our wedding reception are doubling up as winter decorations.

2008 concluded with a trip to PA to meet some Houser relatives that T had never met and Jeffry still can't remember the names of. The rest of our winter was low key, with some local hiking and short trips to the Poconos and Boston.

Summer eventually came, which gave T more time to prepare for the wedding. We spent thousands of dollars at Home Depot to make our house presentable. The monotony of house projects was broken up by some short trips to VA and Vermont.

Our wedding weekend was not traditional. We started the weekend with several competitive games of laser tag and some yummy pizza. We did the deed before a beautiful cascading waterfall in the middle of the woods. Back at the house, we enjoyed an all day delicious barbeque styled open house reception. The next day, we headed to a local amusement park for some enjoyment. Jeffry's car was broken into the next day; but we still closed the weekend with a trip to the Yedinak Farm in Moscow, PA. We took a tractor ride, hung out by the pond, and picked backyard blueberries.

T's long-time friend, Irina, came in for the wedding from Moscow, Russia, with her daughter, Juli. They spent 2 weeks visiting Mystic, Boston, and many other local affairs. It had been 15 years since they'd seen each other!

The summer ended quickly when it was time for T to go back to the classroom, teaching eager young minds in the 4th and 5th grade. September and October were relaxed, but November had Jeffry bouncing all over the Northeast promoting Flextras, his set of UI Components for Flex Developers.

In November, T and Jeffry traveled to Newport, RI, meeting up with the Houser clan for a Cliff Walk and a trip to the Coggeshall Farm Museum. Next, they headed up to Vermont for a Guster concert. Then we had a rural Pennsylvania Thanksgiving meal at Jeff's brother's place in State College, PA. And finally, T got to be a tour guide when another friend from Russia, visited CT!

Our first Christmas together was spent, ironically, apart, a mutual decision to satisfy Jeffry the Homebody and T the Traveler. T went to Williamsburg, VA with her friend Rachel and enjoyed 3 days of sightseeing which included a side trip to Jamestown.

So, that was our Holiday letter; which got snail mailed out last week sometime. I'm not sure what the next year holds for us, but here are some things I expect to do in no particular order:

  • I expect to do more home cooking and add more fruit and vegetables to my diet.
  • There is a chance I'll buy a juicer, funds permitting. The thought of juicing your own veggies holds a strange appeal for me.
  • I did not buy replacement pages for my day timer, instead moving to Google Calendar synced with my iPod touch. So far so good.
  • I expect to have no more conversations about when the decade really starts, or ends.
  • There is a slight chance I'll switch from Blockbuster On-line to Netflix, part due to the streaming service, part due to the fact that if I build an app against the Netflix API I can expense the account
  • I will find a good, simple, bread recipe and finally use our baking stone and peel. I also plan to finally make some Pizza [from scratch] for T. I used to do it all the time with moderate success, but not in ages.
  • I'm going to try to participate in February's National Album Writing Month. Want to write a song or two with me? Are you in the area?
  • I will be a success!

Tales of Monkey Island Review

A brand new tale in the world of Monkey Island is out. After a short walk down memory lane, I sat down to play the Tales of Monkey Island series. Tales of Monkey Island is a single story released as five episodes over the course of six months. I was happy to have an old school style adventure game for today's world, but unfortunately the game lacked some of the polish I'd expect from a non-episodic adventure.

Running the Game

When playing the older games today, getting them to run was an adventure of its own. I wouldn't have expected any issues with such a brand new game, but alas I did have one serious issue. My game machine is not powerful enough to run the game at full capacity. I had to knock the quality setting down from 6, the default, to 3 before I could get beyond the title screen. TOMI comes with no documentation; not even a PDF. It was only through trial and error I was able to find the quality setting and change the setting. This took about an hour, because moving the mouse smoothly across the title screen was not possible at any setting higher than 6. It was a jagged movement, as if the screen only had 6 pixels. Once I figured that out that initial problem, I was able to start the game, things went much smoother. Thankfully each new episode was able to 'find' my settings from the previous episode and I did not go through the same setting nightmare each time.

There is an interesting option in the settings named hint frequency. I wish some documentation would tell me what that means, but I assumed this somehow related to in game hints. I turned it all the way down in hopes of making the games more challenging. By my estimate I spent 5-8 hours on each chapter, slightly more than the estimated 2-4 hours per chapter. I only turned the hints higher at one point in Episode 5 was I was ungodly stuck. It turns out my issue there was a missed screen exit. Once I discovered that exit, I was able to easily solve the puzzle at hand. At some points in the game you do have to walk right at the screen. Getting around in the game will be quite easy, especially if you've played other games in the adventure genre. Unfortunately instead of pointing and clicking to move around, you have to hold down the mouse button and move the mouse. It aggravated my wrist occasionally, but for the most part was not too bad. Beyond that, the game sports the traditional point and click to interact with items.

Onto the Story Already

The game starts out on a ship, and in order to make it seem realistic, the ship actually bobs back and forth on the waves, moving both your view of the scenery and the hotspots you need to click on to and fro. This is a cool effect that you get used to pretty quickly, but I think they should have introduced the game, and therefore the interface in some other manner.

Guybrush Threepwood, our hero, getting ready to fight LeChuck , our villain, with the Cursed Cutlass of Kaflu. Guybrush just needs to finish up the voodoo spell; which doesn't go as planned. LeChuck turns into a human and his demon essence floats throughout the Caribbean infecting pirates. Guybrush ends up on Flotsam Island with a cursed hand. On Flotsam Island all winds blow towards the center of the island, meaning no pirate can ever leave. It is up to Guybrush to find a boat and crew and to solve the wind problem so he can escape and find out what happened to LeChuck and Elaine.

The game plays much like a traditional adventure game. The puzzles are logical enough, often based on using or combining inventory items that you collected along the way. Some require more thought such as solving the map puzzle in Episode 1, and a different map puzzle again in Episode 4. I was impressed with the amount of locations in each game, as I expected them to be heavily watered down due to the time constraints of creating an episodic adventure.

Guybrush's search will lead him to meet up with many old favorites such as Stan--now a lawyer, The Voodoo Lady, and Murray the Demonic Skull. It also introduces the best character to grace a Monkey Island game since Murray: Morgan LeFlay the female pirate hunter. Morgan, like you and I, is a fan of Guybrush. You might even say she has a bit of a starry eyed crush. The two characters play off each other fantastically; in some cases, it mirrors the interplay between Elaine and Guybrush from Escape from Monkey Island.

Episode 1 focuses on Guybrush getting a boat and getting off of Flotsam Island. Episode 2 and 3 focuses on Guybrush finding La Esponja Grande, a magic voodoo talisman to help get rid of the Pox of LeChuck. Episode 4 focuses on using La Esponja Grande in a Voodoo spell; and episode 5 finishes off the story with a final showdown. Episode 5 has a real treat, where you get to play Guybrush as a Ghost and a Zombie, mirroring the first two incantations of LeChuck.

As with many stories, the game raises more questions than answers. It calls into doubt the true intentions of the Voodoo Lady, and she takes a much larger role than in previous games. The characterization of Elaine seems to back flip between the character we all know and love to someone with intentions not quite as clear. Each episode progressively improved in gameplay and story, until episode 5 where the characterization of Elaine slipped and none of the questions raised were ever answered.

What Next?

In episode one you can find treasure maps on-line and explore the jungles of Flotsam Island for more treasure. I thought that this was a great way to add replay value and was disappointed this option was not introduced in future episodes. Even so, while traversing the jungles using a creative map system was fun the first time; it wasn't enough to get me to go through again. The first treasure was a special background for your computer. I thought it was a novel attempt to add replay value to the game and to provide additional benefit to the customers.

I guess now I go into the waiting game. I'll probably replay through the game, possibly on a better computer with higher quality settings, around the time that Tales of Monkey Island 2 comes out, and I hope there is a sequel. I greatly enjoyed the adventure despite the questions it raised. I hope it is leading somewhere and I look forward to joining Guybrush on another adventure, hopefully next year.

Only 20 discount tickets for 360|Flex are Remaining! Get yours now!

I'll be speaking at next year's 360|Flex conference in March 2010. There are only twenty tickets left at the discounted price of $499 before the price goes up to $599. Register now. San Jose is a hot bed of technology and the 360|events in the area always sell out. Don't wait, because once tickets go they are gone.

I'll be speaking about the differences between Flex 3's Halo component architecture and Flex 4's Spark component architecture. I spent a lot of time working on components for Flextras, so I hope to be able to impart some useful knowledge to ya'll. Why else would you want to go?

  • Flex 4 is launching soon, you're not going to get any better Flex 4 information than at 360|Flex, with several sessions dedicated to just Flex 4 features!
  • Sunday is an extra day of hands on on training that is free for all attendees. If you're a beginner go to Garth's Flex 101 Hands-On session. If you have more experience, take a look at the class on the MATE framework or connecting Flex to hardware like the Arduino.
  • Flextras will be offering a special gift to all attendees that you don't want to miss.
  • The Flex Show will be podcasting the event again too.
  • Did I mention you get to meet me in person? If 100 people sign up using my own personal registration link; I'll shave my head before the event, or during the event if that is your preference. I get a lot of karma points if you use the link and you costs you nothing extra.

Monkey Island 4: Escape From - Classic Game Review

A brand new tale in the world of Monkey Island is out, and I'm hoping for a fun old style game in the vein of the classic adventure genre. I went ahead and pre-purchased all five episodes, and can't wait to delve in. But, before starting to the new stuff, I decided to refresh my memory on that which came before. This is a review of my experiences with The Escape from Monkey Island. I think this is my favorite game in the series.

Running the Game Running

Like Monkey Island 3, I had Monkey Island 4 on CD. Unlike Monkey Island 3, MI4 is not supported by SCUMMVM. I was on my own getting the game to run. Thankfully the game installed and ran with no problems. Unfortunately, this Monkey Island is buggy in the "CD" state, so I had to search around and find a patch, here or here. For some reason my mind told me to look for patches before starting the game; perhaps I have some deep routed ill memories about this title somewhere below the surface.

Even with the patch, there was still a show stopper bug. When talking to some chess pirates playing , if you don't finish the puzzle the first time entering the screen the game locks up when you come back later to finish. Unfortunately, you can start the chain of events without knowing there is an actual puzzle going on yet. I had to restore a previously saved game going quite back a ways in order to get past the bug. In retrospect I remember having this problem the first time around too.

There is also a 3rd party replacement for the MI4 loader, which supposedly gives you an easier way to install the game, download the patch, and change various settings. I could never get it to work, unfortunately, so can't comment on it. The idea sounds promising, however.

Getting used to the Interface

Escape from Monkey Island is the first 3D Monkey Island Game. I'm not sure if the 3D rendering adds anything to the game, but it didn't detract either. The look of the game was very similar to the style of the previous game; which had the visual appeal of a cartoon. I don't mind cartoons, so it was all good.

This game uses the keyboard as the primary interface, so no more point and click. I remember this frustrating me greatly the first time around. Imagine a game from the year 2000 that didn't use a mouse? This time I didn't mind the keyboard usage. It took a while to get used to, but once I was there it was fine.

That was a great Honeymoon, are we dead?

The game starts with our heroes, Guybrush Threepwood and Elaine Marley, coming back to Melee Island from their honeymoon. Unfortunately, Governor Marley has been declared dead and they are trying to demolish her house. As Elaine goes off to get herself declared undead--no not like that---Guybrush tries to stop the house demolition. Along the way we reintroduce LeChuck as a political candidate in the Melee Island Governor race, Ozzie Mandril an Australian real estate developer turning all that is piratey into big tourist traps and a quest to unravel the secret of the Marley Heirlooms and discover the ultimate insult.

The tourist traps offer great ways to make a mockery of pop culture, taking stabs at Planet Hollywood, and Starbucks.

The puzzles are logical and somehow manage to avoid the endless point and click until something works phenomena that exists in much of the genre. By introducing some random element into the puzzles, the puzzles are slightly more varied and require some thought to solve. For example, in one point you need to figure out how a filing system works to find the hideout of a thief on Lucre Island. The filing system is consistent, but the name changes, so each time through the puzzle is slightly different. As you would expect, Guybrush has to find a ship and a crew. Each adventure leads to the next, eventually leading to Monkey Island a final show down with LeChuck.

In part 1, LeChuck was a ghost. In Part 2, LeChuck was a zombie. In part 3 he was a demon. This time they switch between all three personas as LeChuck's character takes shape. I especially liked seeing Ghost Pirate LeChuck rendered with "modern" capabilities.

The insult sword fighting idea returns in this game as Monkey Combat. You need to shout a series of nonsense monkey words to move to a position. Each position wins over a different position and you banter back and forth w/ your opponent. This is the weakest point in the game, unfortunately. It is tedious to figure out the magic commands and it feels like just a roadblack to enjoyment.

The banter between the Elaine and Guybrush is fantastic and for me really nailed the essence of the characters. Guybrush was a bit more naïve, and focused on comic relief. He played his character as if he were a kid in a candy store, and everything he explored was new and exciting. Elaine, on the other hand, takes the more serious stance on things. The voice acting and characterization of all the characters is what really made the game a joy to play.

What Next?

Well, I'm out of legacy Monkey Island games to add to my playlist. I guess it is time to move on to something more recent, the Launch of the Screaming Narwhal. This is my first foray into episodic gaming and I'm not sure what to expect. I hope the five episodes of Tales of Monkey Island are equal (or greater) than a single game. We'll have to see how it goes.

How does Flex Size Components?

This question comes in from Corey

I'm a newbie to the world of web development and Flex. I'm currently working on a project that will allow visitors to post stories and allow other users to comment on these stories. Similar functionality to Facebook's "wall." Would you describe for me how to set the size of components (for this example, let's use the standard panel component) to fit the content submitted by the user? Any other helpful tips you feel may be pertinent to this topic are always welcome as well. Thanks.

Well, my first impulse is to say that Flex will automatically size components to fit their content. But, there are some restrictions to that. For example, you can use measuredMinWidth and measuredMinHeight to give the component a minimum size. Other components being placed and sized can also be a factor in how everything is laid out. At the end of the day, however, a component is always sized by it's parent.

If you want to give that parent suggestions, you can implement your own measure method and use that to set the measuredWidth, measuredHeight, measuredMinWidth, and measuredMinHeight. UpdateDisplayList and/or CommitProperties may also help you with sizing; but if this is your first Flex Component I'm not sure if I'd start there.

To create something similar to the facebook wall, you might start with a List class and the variableRowHeight property. Each wall item would size itself inside the list. You could add the commenting feature as a pop-up somehow. Giv me an hour and I'll think up a dozen other ideas to implement something like that.

You can always ask me your question here, or stop by a Flextras Friday Lunch session and ask me in person. If you're really inspired to show you support check out The Flex Show's sponsorship drive.

Where can I find a Flex Calendar?

This question comes in from Andrew, who heard me talking about the Flextras Calendar in the last episode of The Flex Show.

Hi Jeffry, I just listened to the October News issue of The Flex Show podcast. I heard you mention a calendar app you've been working on. I've been tangling with the Flex Community Blog calendar app which is based on the Quietly Schemeing calendar app. Both of these use the CalendarDisplay class which looks like it was distributed by Adobe in 2006, is your project based on this class? Will your calendar be available to the community? If so, can I take a look at it?

First, thanks for listening to the show.

The Flextras Calendar is something we are building from scratch, so it is not based on the Quietly Scheming / Ely Greenfield code. It will be a commercial component from Flextras, my Flex Component company.

You can find out more information about the Flextras Calendar here.

Also check out the ASDocs and the API Explorer demo.

The Flextras Calendar is built for flexibility and focuses on using renderers so you can customize to your hearts content. The API is a mash up of the DateChooser and List classes.

Although, we have not finished the development of it yet, we have made it available as a preview release and everyone who buys the preview release will be automatically upgraded to our unlimited domain edition. We're pretty sure that the API and classes will be refactored a bit in the final release than the preview release.

For our thoughts on building a Calendar, watch The Flex Show Video series on creating Flex Components.

If you want early access to the Flextras Calendar [without buying the pre-release version] you'll need to join our beta program. Sign up for an account at Flextras.com. You'll be asked to verify your e-mail address, and once you do, you'll be able to access a "join beta program" link from the account menu. I'd love to have some slightly more active beta testers.

I love the easy questions. But, don't let that stop you from asking the hard ones.

Support The Flex Show in 2010

Every once in a while on the Flextras Friday Lunch the conversation turns to business related topics. I talk about the difference between infinite digital goods and scarce goods. Digital goods can be easily copied and distributed. Scarce goods, such as services, are not easily replicated.

The record industry has been hit hard by this market switch. It is easy to find the music of many bands for free out there on the Internet and this is eroding the business of selling music. Movies appear to be following the same path and I suspect software isn't too far behind. When the "cash cow" goes away, how do you make a salary?

Content Creators in the Digital Economy

One method for making a living is to find people who find value in their work, then give them a way and reason to support them. Many musicians have started giving away mp3s in order to sell other scarce goods.

One such scarce good is the ability to create more music; many musical acts have connected with fans to fund the production of their next album. We've decided to try this approach with The Flex Show.

Support us, we'll give you stuff

About a week ago we launched a pledge drive, so our listeners can support The Flex Show in 2010. For as little as $5 we'll send you some stickers and thank you on the web site. For a bit more, we'll thank you in an episode. We didn't stop there.

You can control aspects of the show. Do you want to replace our theme song? Would you like more screencasts? Do you want to join us for a recording and approve the final edit? Or perhaps you'd like to see us go weekly in 2010? All these things are possible. We even have a few fun options in there, such as getting together for lunch, or hanging out at the next 360|Flex conference.

  • Have you been listening to The Flex Show? We have over 110 episodes now.
  • Do you know of a better, free, educational resource out there for Flex Developers?
  • Would you like to see us keep going?

Then choose your option and show us you care. Thank you for the support.

More Entries

All Content Copyright 2005, 2006, 2007, 2008, 2009 Jeffry Houser. May not be reused without permission
BlogCFC was created by Raymond Camden. This blog is running version 5.9.2.002.