There’s been quite a bit of buzz lately about “WPF/E”, or “Windows Presentation Foundation Everywhere,” a code word for Microsoft’s newest browser plugin and implementation of their Windows Presentation Foundation. This week, Microsoft released a Community Technology Preview (CTP) of WPF/E. I downloaded and installed their plugin and SDK and decided to see what I could do.

The plugin, and its drawing capabilities, were decidedly Flash-like. However, the documentation led me to believe that the entire “movie” – all the shapes, strokes, motions, and events – must be scripted in Microsoft’s XAML language, as opposed to being created in a nice drawing interface such as Flash or Illustrator would offer.

This couldn’t be. There is no way your average graphic designer would take kindly to coding all of this into XML. In fact most designers shriek, run away, and hide at the very thought of code. There has to be some kind of GUI to do this if WPF/E is ever going to be taken seriously by the design community.

After a bit more investigation, I found that Microsoft recommends “Expression Web Designer” to develop pages and “Expression Web Blend” for creation of WPF/E objects. Of course, this information was buried, in that special MSDN way of hiding information in plain sight. Initially, the Expression pages said that to use Expression Web Designer, one must first install the .NET Framework 2.0, and then install the designer software, and the Expression Web Blend was no longer available.

So after some more downloading, I installed the framework and Expression Designer, and fired it up to have a look at the latest Macromedia-Killer, which turned out to be a clone of Dreamweaver, with no mention of WPF/E anywhere.

After even more investigation, I found the trial download of Expression Blend, once again hidden in MSDN’s own unique way of hiding only the stuff someone might actually want to see, hidden amongst endless blobs of buzzwords and Microsoft horn-tooting. Plus, I now had to upgrade to .NET Framework 3.0.

Another round of downloading and installing, and finally, I was ready to for this ever-so-hyped and cleverly-hidden masterpiece of Microsoft innovation and competition-killing.

What I got was, well, stupid:Microsoft Blend - look familiar?

I always get a kick out the general assumption that monochromatic gray colors automatically makes you “edgy” and “hip.”

Also, I couldn’t find any way to change the fill color of the objects I had drawn onto the Stage …err, sorry, I mean the “Canvas”… The Paint Bucket seemed incapable of its basic Paint Bucket duties.

Scripted events were clumsily assembled in a panel drop-down interface, allowing the user to select first the object, then the event, then the action. For lack of a better example, it reminded me of the email-filtering in Outlook.

On the other hand, I did get an answer to my question: Yes, there is a graphical drawing interface to create XAML for a WPF/E page.

But why would you use it?

, , ,

I’m attempting to claim this on Technorati.

Technorati Profile

I worked really hard on that title.

An astute reader wrote in regarding my previous post about using Array.join("") to pull HTML tags from XML. He said that all this can be avoided by simply using CDATA in the XML document and pulling out the data with the .nodeValue property.

This, as Luther would have us say, is most certainly true, and it’s the simplest solution to the problem. I’ll even admit to being teh st00pidz for not mentioning this right from the start.

However, what if we needed to do both? Suppose, for example, you need to write an XML parser to parse data from a variety of publishers. Publishers, as we all know, are an unpredictable bunch. So publisher #1 sends out an XML file with their content enclosed in CDATA, and publisher #2 does not. Now what?

We’ll need a function to convert both CDATA and non-CDATA data into a universal format that can be displayed in an HTML textfield. Because the nodeValue method will only reliably return CDATA, I’m going to use the Array.join("") method.

Again, assuming we’ve loaded and parsed the XML file, let’s first get a string out of it:

[as]
var str:String = mx.xpath.XPathAPI.selectSingleNode(xml.firstChild.childNodes[0], “item/description”).childNodes.join(“”);
[/as]

Now, because the function requires some searching and replacing, let’s add a replace() function to the String prototype:

[as]String.prototype.replace = function(replaceString, withString) {
var myArray = this.split(replaceString);
return(myArray.join(withString));
};[/as]

And finally,the conversion function:

[as]function convert(str) {
if( str.indexOf(“>”,0) != -1) { // if the string has come in as CDATA, it will not have “>”,”>”);
}

var mc:MovieClip = _root.createEmptyMovieClip(“converterMC”,0);
var htmlconverter = mc.createTextField(“htmlconverter”,mc.getNextHighestDepth(), -500,-500,100,25)
htmlconverter.html = true;
htmlconverter.htmlText = str;
var converted:String = htmlconverter.text;
mc.removeMovieClip();
delete mc;
return converted;
}
[/as]

What in the world is going on here, anyway?

When Flash pulls CDATA out of an XML document, all of the HTML entities will become escaped. So, “<” becomes “&lt;“, etc. If there’s already an escaped “&lt;” in the data, it comes back “double-escaped,” like this: &amp;lt;.

The first part of the function, the if block, checks for the existence of a “<” character. If one of these exists, then the text has not been escaped, and therefore, we can safely assume it is not coming in as CDATA. Then, the replace calls turn the HTML less-than and greater-than tag markers into escaped entities, and “double-escapes” any already-escaped entities. In other words, it converts the string into the same format as any CDATA. Now, it’s conversion time!

First, the function creates a text field on the stage and sets the html property to true. Then, it places the newly converted string into the htmlText property, which will cause the textfield to interpret the HTML. In this case, it takes escaped HTML text and converts it to non-escaped text. The contents of the textfield will now be proper HTML, with <> symbols around the tags, and escaped entities elsewhere, if necessary. This can then be set as the htmlText of another field, and will display properly.

If there’s ever a need to convert HTML text to non-HTML text, I highly recommend this method. Basically, it’s a nice quick way to strip any HTML tags, or in this case, interpret escaped entities. You could also put an HTML textfield on the stage, set its htmlText, and then pull out its text property, but I prefer this way because it’s a purely ActionScript solution.

By the way, does anyone know if there’s a proper term for “non-CDATA“?

, ,

It seems that documentation and clear examples for how to customize Flash 8’s ScrollPane component are somewhat scarce. In fact, just a quick Google search yields many messageboard postings bemoaning the difficulty of using ScrollPane, with little to nothing in response.

It’s important to note that the old methods of UI Component customization – setting values for “face”, “arrow,” “scrollTrack,” and the like, seem to have fallen by the wayside.

The recommended method these days is something much more in-depth and complicated, with poor documentation thrown in just to make sure you don’t get it right the first time. For example, the documentation on LiveDocs provides the following table of applicable styles for ScrollPane:

Style Theme Description
themeColor Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen".
borderStyle Both The ScrollPane component uses a RectBorder instance as its border and responds to the styles defined on that class. See RectBorder class.The default border style is "inset".
scrollTrackColor Sample The background color for the scroll track. The default value is 0xCCCCCC (light gray).
symbolColor Sample The color of the arrows on the scrollbar buttons. The default value is 0×000000 (black).
symbolDisabledColor Sample The color of disabled arrows on the scrollbar buttons. The default value is 0×848384 (dark gray).

Great! Looks like we can change the arrow or track color of the scrollbar on a ScrollPain instance. All you need to do is set myScrollPane.scrollTrackColor, right?

Wrong.

Try it. Put a ScrollPane on the stage and set that scrollTrackColor. Set it all day long until you’re 0×0000FF in the face. You won’t see any changes to the scrollbar’s appearance.

Why?

Pay close attention to that “theme” column. It provides the key to why your customization isn’t going as planned. If you want to customize the scroll track or arrow color, those properties are available but what isn’t mentioned here is that you must first install the “Sample” theme from Macromedia’s libraries. A detailed description of how to do this is available in “About Themes” on LiveDocs.

So, we’ve dragged the Library over, installed the sample theme, and Presto! We now have a customized scrollbar color. We can also set symbolColor to change the color of the arrows.

It’s only a slight improvement. The problem is, we’ve now been left with chunky, gray, Windows 3.1-style scrollbars, and the only ActionScript customization options are for the arrows and the track.

You can improve the look and feel of the arrows manually, by editing the symbols in the Scrollbar Assets folder we dragged over during the Sample theme install. But who has the time or energy for that?

A little bit of digging around in the symbols that the Sample theme carried over reveals some hidden, undocumented goodness: there is also a highlightColor and shadowColor property available to these scrollbars. highlightColor applies to the “main” color of the arrow buttons and “thumb” element, while shadowColor is the small shadow to the bottom right of each piece.

(To see this for yourself, have a look at the “BrdrHilght,” “BrdrFace”, “BrdrBlk”, and “BrdrShdw” symbols.)

Here’s a diagram of the different parts of the scrollbar and where the different colors apply. Note: Please, never, under any circumstances, for any reason, use a color scheme like this. I only did it so I can show where the different parts are.

Sometime’s, it’s really amazing what you can find just by poking around in Macromedia’s samples.

, ,

ObjectDumper

Like many Flash developers, I was frustrated at trying to see the contents of complex ActionScript objects and being left with the irritatingly vague “[Object object]“

So it should come as no surprise that I was ecstatic at the discovery of the ObjectDumper. It’s a hidden, undocumented tool in Flash for tracing (or otherwise outputting) all the contents of an object, in a friendly, bracketed format. Macromedia’s Jen DeHaan explains it in detail.

This tool has proved invaluable to me, and I highly recommend it.

,

I’m going to bite the bullet and do this.

I messed around with some free, open-source (read: unnecessarily complicated) blog systems, while still in the process of deciding whether to turn my old portfolio site into a blog.

Then, quite by accident, I discovered that my web host offered WordPress as part of my hosting package. Score! No more password.php, config.txt, install.sql, you know the drill. I just clicked the button and now I have a blog. They get an A+ for user experience.

The originally Nerdabilly.com was hatched in the fall of 2001 as an online portfolio and showcase of my college works. Now, 5 years later, the site had only ever had one major overhaul and was showing the signs of its age. I’m at a point in my life where experience speaks for itself, and I’m finding that an online portfolio and resume may be a bit more work than it’s really worth.
I work mainly as a Flash developer now, although I do find myself delving into JavaScript and XML on occasion, so expect some insight into my daily trials and discoveries of the world of Flash.

What does nerdabilly.com mean, anyway?

Funny you should ask!
The name “nerdabilly” came to me in a dream during the summer of 2001. I had fallen asleep at my desk while working a temp position at a soul-crushingly-dull call center operation. The original vision was to have a site showcasing my own work as well as tutorials and info on anything I deemed tutorial-or-info-worthy. In some ways, this blog is a continuation of that idea. The name is a combination of “nerd” (which, at this point, needs no further elaboration) and “rockabilly,” and was inspired by the tendency of rockabilly fans to add the suffix “-(a)billy” to any imaginable root.