Perl Docs vs. Other Docs

I’ve been fussing with Flex this week (as I threatened earlier) and even with my fabulous experience of the tutorials, I have to admit that I’ve been seriously spoiled by working with Perl for so long. It’s such a mature language that someone else has *always* done something similar to what I’m trying to do, so I can find something to crib off of and get most of the work done. Even outside of CPAN, folks have code samples and examples and conversations on mailing lists explaining why things work (or don’t).

Flex is not so much with the easy documentation. I consider myself an expert on finding the answer to puzzling questions, and this week I’ve been faced with many, many puzzling questions which are not easily answered in the book(s) I have nor on any site I can find. Sure, someone has generally answered the basic question but I never seem to need help with those.

For example, yesterday I tried to figure out how to coerce an XMLList into an Array. Seems like it should be simple. I have a list of XML things. Please tell me what their labels are. Thank you. Perl wouldn’t have any trouble giving me an array from something array-ish. But no. I spent a couple of hours trying to shove the square peg into the round hole, and at lunch went by Borders to peek at one of the books there and discover that the only way to make an Array out of XMLList entries is… to iterate over the list and shove them in one by one. Ick.

Turns out I didn’t really want to put an array in there anyhow, since I want to be able to change the list on the fly and do magical things with it – so passing in the collection itself was the right thing. But hey, the yak needed shaving, so I spent the time to do it right.

And this morning I wanted to do something fairly simple. I wanted to make a button glow when you push it, and unglow when you push it again. This is not hard. I want to maintain the state of the button in a variable which I’ll use elsewhere. Surely someone has wanted to do this before… but I couldn’t find any examples.

I did, however, figure it out, so I’ll put it here in case anyone else is trying to glow and unglow buttons in Flex.

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>

public var Glowing:Boolean = false;
public function glowMe():void {
if (Glowing) {
buttonGlow.reverse();
Glowing = false;
} else {
buttonGlow.play();
Glowing = true;
}
}

</mx:Script>
<mx:Glow id="buttonGlow" color="0x99FF66" alphaFrom="1.0" alphaTo="0.0" duration="100" target="myButton"/>
<mx:Panel x="10" y="10" width="200" height="300" layout="absolute">
<mx:Button x="40" y="60" label="View" id="myButton" mouseUpEffect="{buttonGlow}" click="{glowMe()}; myLabel.visible=true;"/>
</mx:Panel>
</mx:Application>

Dialogue & Discussion