Sunday, March 25, 2007

work work work work work

This weekend, this very weekend in which we are right now, is the first weekend in over five weeks that I'm not working.

Just over five weeks ago, I started a new company.

This was just after the two-and-a-half weeks that I spent learning some new programming skills and a new development platform that isn't based on an IBM midrange system.

So I haven't taken any time off in over a month, until now.

(pause for dramatic effect here).

I have no idea what to do with myself.

It's a strange feeling! I love working for myself - this is my third company in sixteen years - and when I work, buddy lemme tell ya I work. So for a over a month I've been doing 12 to 18 hour days, an all-nighter or two for good measure and still feel that I can't seem to work quickly or efficiently enough. And I jump out of bed every morning eager an excited to get going. Drink coffee, get to work. That simple, and exactly how it should be. So now, when I give myself "nothing" to do, I have no idea what to do. As in: have a life. What? How?

So yesterday and today have been "have a life" days. "Smell the flowers" days. It's important, I know, but still... it feels strange. Anyway, I had no intention of sitting in front of my computer, but here I am, and for the first time in eons adding to this blog. [ed note: this is crossposted from my other, older blog] Not exactly "having a life", but in a few I'm up and out and going somewhere interesting. Or at least somewhere with beer in clean glasses. Maybe I'll take my camera - the one that uses real film - and go shoot things.

I can't bring myself to blog about politics. I'm still burned out on blogging about politics, though I'll still talk about it off-blog. It's all a mess - what more is there to say?

So, today, a rare day off. Then tomorrow, back at the desk working to my heart's content.

Friday, March 23, 2007

Creating a new hit-area for a button in Flex Builder 2.0.1

I ran into this yesterday, and thought I'd put it up here & share with the class.

I have a button in mxml:

<mx:button x="-22" y="294" id="reallyBigButton" stylename="reallyBigButtonStyle" buttonmode="true" usehandcursor="true" creationcomplete="addHitArea()" />
It's really big, this button, and I only want a portion of it to be the hit area. The button is skinned via css with a .png file, and it covers about a sixth of the pixellated real-estate. Not good.

So notice that on creationcomplete it calls a function addHitArea().

That function looks like this:

private function addHitArea():void{
var newHitArea:Sprite = new Sprite();
newHitArea.visible = false;
newHitArea.mouseEnabled=false;
newHitArea.graphics.clear();
newHitArea.graphics.beginFill(0x000000, 1.0);
newHitArea.graphics.drawCircle(117,216,80);
newHitArea.graphics.endFill();
reallyBigButton.addChild(newHitArea);
reallyBigButton.hitArea = newHitArea;
reallyBigButton.validateDisplayList();
}
Notice a couple of things: the new hit area doesn't need to be visible. And it should have mouseEnabled set to false. You want the button to reference the button sprite for size and location, but not to capture control of any click events. Click events are still captured by the button.

Why the graphics.clear? I'm not sure, other than good-practice. Clean the board before scribbling, I suppose.

Keep in mind that the coordinates of the hitarea sprite are relative to the coordinates of the button, not of the stage or the button's parent.

Saturday, March 17, 2007

as3syndicationlib and ATOM feeds

This needs review, but for anyone else reading Atom feeds using the as3syndicationlib, you may have found that feeds with no content tag for an entry, but with the summary tag, don't process correctly. I.e., feeds that use summary and not content don't get processed as intended.

As a quick fix, I modified Entry.as in src.com.adobe.xml.syndication.atom below the comment block at line 194.

I'm still working on this, and so this code needs work. It's not the prettiest, but it's a start. Please note that indentations didn't make it from eclipse to blogger.

/*
*JDR -- Changed assignment to content.
* Also, detect for or tag usage. Blogger uses summary tag, but feedburner et.al. use content tag.
* I'm also loading the same source for XHTML or not, since ATOM feeds with XHTML I tested
* don't have the x.atom::content.xhtml::div contained.
* And, type="html" is causing >>if (content.type == "xhtml") to valuate true in the debug session.
*
*
*/
public function get content():Content
{
var content:Content = new Content();
content.type = ParsingTools.nullCheck(x.atom::content.@type);
content.src = ParsingTools.nullCheck(x.atom::content.@src);
if (content.type == "xhtml")
{
// this line needs to be changed, but for now, return flat content.
content.value = ParsingTools.nullCheck(x.atom::content);
}
else
{
content.value = ParsingTools.nullCheck(x.atom::content);
}
if(content.src != null || content.value == null)
{
content.type = ParsingTools.nullCheck(x.atom::summary.@type);
content.src = ParsingTools.nullCheck(x.atom::link.(@rel=="self").@href);
if (content.type == "xhtml")
{
content.value = ParsingTools.nullCheck(x.atom::summary);
}
else
{
content.value = ParsingTools.nullCheck(x.atom::summary);
}
}
return content;
}


See here for more info on Atom.

Thursday, March 15, 2007

AS3 object mistake

Most of my experience in coding is with a procedural language on an IBM iSeries. And on occasion I fall into old habits in as3. For example, I coded:

var var1:Text = new Text();
var var2:Text = new Text();
var1.text = "Var 1 text";
var2.text = "Var 2 text";
trace(var1.text, var2.text);
var2=var1;
trace(var1.text, var2.text);
var1.text="Some new var1 text";
trace(var1.text, var2.text);

and didn't expect these results:

Var 1 text Var 2 text
Var 1 text Var 1 text
Some new var1 text Some new var1 text


Oops. Old (and bad) habits die hard. In RPG, I'd expect the system to take care of instantiating a new object, so a change to var1 didn't also change var2. I know better in as3, but it had me puzzled for a few minutes. This works:

var var1:Text = new Text();
var var2:Text = new Text();
var1.text = "Var 1 text";
var2.text = "Var 2 text";
trace(var1.text, var2.text);
var2=var1;
trace(var1.text, var2.text);
var1 = new Text();
var1.text="Some new var1 text";
trace("Final var1: " + var1.text, " -- Final var2: " + var2.text);

and yields:

Var 1 text Var 2 text
Var 1 text Var 1 text
Final var1: Some new var1 text -- Final var2: Var 1 text


Note new object instantiation before the last "Some new var1 text" assignment.

Learning curve.

Wednesday, March 14, 2007

One month

Today marks one month of working on my own company! After two and a half weeks of training, teaching myself Flex and AS3, and remembering half of what I've forgotten in python, I started actual work on Feb 14.

One month. Blew right by. But the long days and weekends are paying off, though slowly.

In the meanwhile, here's another little tip for FlexBuilder 2.0.1: before you refactor any code, make sure you remove all watch expressions from the debugger view. I was able to freeze eclipse in subsequent debug sessions after I changed a couple of properties in a class while said properties were being watched. Removing the watch expressions from the debug view & replacing them to the debug view when needed seemed to clear up the problem.

Sunday, March 11, 2007

flex theme use

I recently needed to "grey-box" something - I needed to check the flow from use-case to use-case throughout the app. Rather than use the standard flex themes, I used Juan Sanchez's "Shadow" theme.

Usually we think of themes and skins in terms of final product - at least I did until about a week ago - but there's a call for their use in any situation. What impression do we give our audience about the product? What are we communicating about our attention to detail, our understanding of aesthetics, and what first impression are we inspiring people to infer, or feel?

I plan on using more themes as different situations arise, and I use "Obsidian" for my own personal tools just because I like it & it feels good to me. And of course content and functionality need to be high-quality, but I've found that in many cases there are more than a few people in a room who, when asked why they went with our product (back a few months ago when I had a job) was that "it just felt right". Hm. Not an answer Descartes would be happy with, but a valid and valubale answer none-the-less.