Archive for November, 2008

0

If you haven’t already realized it, XML has fast become the backbone of data exchange across multiple platforms, applications, and environments. XML is fun!

Because of that, having an understanding of XML, and being able to quickly use it (and abuse it?) inside Flash has become a requirement. By understanding, I mean, in the very least, being able to load XML data into your various applications and projects.

Here’s a simple XML loader, using AS 3.0, which is vastly different from AS 2.0. In AS 2.0, one had to “hack” it into submission, and some of the ways in which data was retrieved was a bit obtuse (IMHO). With AS 3.0, Flash has been revamped and now interacts with XML by implementing ECMAScript for XML (E4X), which is an official language extension for working with XML. Neato!

The files I’ve included in the zip at the end of this post are simpleXML.fla, XMLLoader.as and simple.xml. Let’s go through them:

simple.xml – all the data being pulled into Flash. Simple layout, basically a list of “superfriends”.



	

		Bruce Wayne
		Batmobile
	
	

		Clark Kent
		GMC Truck
	
	

		Joe Kerr
		Clownmobile
	
	

		unknown
		Modified Garbage Truck
	
	

		Robert "Bob" Parr
		POS Microcar
	

simpleXML.fla – the main Flash document. Imports XMLLoader and instantiates it. Has an accessible, dynamic text field on the stage named superText.

XMLLoader.as – does all the work. Loads XML from a defined XML source (passed from simpleXML’s call to XMLLoader). Once loaded, adds all data sequentially to a string variable, then uses that to populate the text field with the data parsed from the XML source.

package {

	import flash.display.MovieClip; // enable access current timeline
	import flash.text.TextField; // enable access text field
	import flash.events.*; // enable reference to load event
	import flash.net.*; // enable URL classes, methods

	public class XMLLoader {

		private var _url:URLRequest; // request for the data source
		private var _xml:XMLList; // xml object
		private var _loader:URLLoader; // actual loader
		private var _list:String; // string var to encapsulate data
		public var _text:TextField; // text field target

		public function XMLLoader(url:String, mc:MovieClip) {
			_text = mc.superText; // specify location of text field
			_url = new URLRequest(url); // get request
			_loader = new URLLoader(_url); // load requested data
			_loader.addEventListener(Event.COMPLETE, XMLComplete);
		}

		private function XMLComplete(e:Event):void {
			_xml = new XMLList(_loader.data); // _xml now contains the data as an XML List
			XMLProcess();
		}

		private function XMLProcess() {
			_list = "";
			for each (var _friend:XML in _xml.*) {
				if(_friend.title !== null) {
                                       // for each child in the node,
                                       // format a human-legible sentence with the data
					_list += _friend.title + "'s name is really " + _friend.name +
                                                   " and drives a " + _friend.car + ".\n\n";
				}
			}
			XMLShow();
		}

		private function XMLShow() {
			_text.text = _list; // transfer formatted data to text field
		}
	}
}

Hope this shows first of all, how significantly easier it is to deal with XML in AS 3.0, and how flexible it is, enabling you to twist it, roll it, dice it anyway you want when you throw it at your project and/or application.

Happy Coding!

simple_xml.zip

0

Hopefully many of you, if you do happen to be reading this, are reading near friends and family, warm homes, happy fun, and good food and drink! Happy Thanksgiving!

I recently had my Fall Dinner Party and aside from going as planned, the people I mixed together all got along and enjoyed our evening of fun, food, and fellowship. And, although I did spend more time on other parts of the meal, apparently it was the cornbread that caught people’s attention. Which is slightly humorous to me, seeing as how it’s a pretty damn basic recipe. HOWEVER – sometimes it’s the simplest things that bring the most pleasure. Hopefully you’ve experienced that at some point in your life, and you can think of that and go “yeah, actually – life worked best in those moments…”

The original recipe comes from the cookbook that should be in every American’s home: Better Homes and Garden’s Cookbook, which has been around since 1930. It was updated for its 75th Anniversary, and it is still the great cook book to have in the kitchen. It even comes ring-bound, which is perfect for laying around the counter while preparing foodstuffs. Seriously! It may not look like much, but it either acts as a resource for full recipes for me, a dictionary of terms, or as a launchpad for a recipe of my own. I’m just sayin’…

Here’s the recipe, make sure to read the notes and trivial knowledge afterword.

Chile Cornbread

– makes one loaf (16 slices)

1 cup all-purpose flour
¾ cup cornmeal - see notes below
2 – 3 tablespoons sugar
2½ teaspoons baking powder - see notes below
¾ teaspoon salt
2 eggs, beaten
¾ cup milk
¼ cup Half and Half cream
¼ cup cooking oil
1 tablespoon cinnamon
3 – 4 Serrano chiles, minced - see notes below

1. Preheat oven to 400˚F.
2. Flour mixture: In a medium bowl, stir together flour, cornmeal, sugar, baking powder, cinnamon, and salt; set aside.
3. Egg mixture: In a separate bowl, combine eggs, milk, Half and Half, and cooking oil.
4. Add egg mixture all at once to flour mixture. Stir (or whisk, or beat) until blended completely.
5. Add chiles; mix thoroughly.
6. Pour batter into a well-greased or well-buttered pan. Bake for 15 – 20 minutes or until a wooden toothpick inserted near center comes out clean. Cut into wedges. Serve warm.

NOTES:
When I go shopping for ingredients that I know will be involved in cooking from scratch, or very close to scratch, I try to find products that have the least amount of shit chemicals added to them, for whatever-the-hell reason some company decided that was a good thing. I also have found that these same products tend to be the least marketed, and the least attractive looking packaging. I tend to find this to be a good sign of the quality.

For this recipe, corn meal is your main ingredient. Without it, you don’t have corn bread. You have flour squares with a slight yellow tint. Best corn meal I’ve found? Aunt Jemima’s Yellow Corn Meal. It’s on the bottom shelf, looks old, and might just be old, but it’s worth it. I have used nothing but Clabber Girl baking powder. There’s always one or two other brands next to it, but Clabber Girl is it.

The other main member are the chiles. I used Serrano chiles, which, according to Melissa’s Great Book of Produce, are mid-hot according to this:

Capsaicin is the incendiary substance in chiles that produces the sensation of heat. Because the amount of capsaicin varies greatly from one chile variety to another, pharmacist Wilbur Scoville developed a system for measuring a pepper’s power. In this system capsaicin content is measured in parts per million, then converted into Scoville units. One part per million is 15 Scoville units. Bell peppers weigh in with zero Scoville units, while the habañero registers a scorching 100,000-300,000 Scoville units.

[Source: Melissa's Great Book of Produce, under "Chiles"]

Serrano chiles have 15,000 – 30,000 Scoville units, so they’re good for adding that little nip of heat, but not so much as to overpower the flavor of the cornmeal.

Feel free to comment or email me if you have any questions.

Happy Cooking! Happy Thanksgiving!

2

It is time to use the Wayback Machine and pull out something that you will either consider to be an abomination, and an audio assault on your ears, or, maybe, just maybe, you will desperately love it because you will NEVER hear this on the radio, a talk show, or anywhere remotely close to the mainstream media outlets.

This is a vinyl from my past. By that I mean, this was one of the records in my parent’s record collection mom’s eclectic record collection (Hey Ev, it was mom’s, not dad’s, right?).

See, as a kid, I was only allowed to own movie soundtracks, classical, and Christian music, that was, in the very least, categorized as soft rock. Yes, there was Christian rock, and even Christian metal, but um… no. That was not allowed in the house. At least, by permission… Fortunately for me, my other options for listening also included my dad’s collection, which was an extensive jazz and Beatles collection. Mom had random stuff like this, really old style Christian chorale music, and loads of classical. Let me just say that having had that kind of forced background in music definitely gave me a range of tolerance and appreciation that would be hard to match, especially if your background was mainly radio and mainstream or just off mainstream music sources. It’s why I can sing along to pretty much any musical that was out from the 1950s through the 1980s. It’s why I know the lyrics, and can sing along to Perry Como. Yeah. (See? Me growing up in Texas does NOT mean I’m a fan of country music. I am not. Ever. Unless it’s Johnny Cash.)

Ruben Rodriguez was a Latin rocker in the mid to late ’60s. You’ll find that his sound is similar to Richie Valenz, only Ruben has a bigger band (see the album cover as proof). And yes, there’s a version of La Bamba on this album. Not sure exactly what number or what year this album came out, but you gotta love the full, insanely long, title: The Utterly Fantastic and Totally Unbelievable Sound of Ruben Rodriguez and his Guadalajara Kings!

Totally! Unbelievable! (dot cooommmmmmmm)

I grabbed this record because to me a: it has sentimental value (mom is gone), and b: there are some pretty damn groovy tracks. Yes, I said groovy. Oh my!

Among the tracks on this album, you’ll find a couple of gems: Guadalajara and La Malagueña. If you’re a fan of Kill Bill, you’ll recognize La Malagueña, and frankly, I like this version better than the one on Kill Bill, performed by Chingon. Listen to their version on YouTube. Also note the two “gringo” tracks, It’s Not Unusual [iTunes link] and The Shadow of Your Smile, most notably performed by Tony Bennet [iTunes link].

Ruben Rodriguez has a very, very brief page on Wikipedia. They actually have a profile on MySpace!

Artist: Ruben Rodriguez
Album: The Utterly Fantastic and Totally Unbelievable Sound of Ruben Rodriguez and his Guadalajara Kings!
Tracks:
1. Ay Jalisco
2. Cu-cu-rru-cu-cu Paloma
3. Cuando Calienta El Sol
4. Go Burrito Go
5. Guadalajara
6. It’s Not Unusual
7. La Bamba
8. La Malagueña
9. Maria Elena
10. The Shadow of Your Smile
11. Vida Complicada

Want the whole thing? Yeah? [get it here ]

¡Hasta mañana!