Friday, February 29, 2008

Flexible Arrays in AS3

posted by John Blanco @ 10:33 AM


Yeah, so for years I've been coding in AS1 and now I'm finally free. FREE! FREE! So now I'm doing AS3, and I'm very comfy with it, but like every day I find new stuff AS3 does to make my life easier.

So here's a lesson on AS3 Array methods.

Arrays in AS3 are a lot more powerful than they used to be, though many Actionscript programmers like myself haven't caught up yet. Well, here ya go.

How To Use These Methods

All of these methods have a similar signature. Specifically, the argument callback, which is a function that takes the following arguments:

  • element:* - the element of the array
  • index:int - the index of the element of the array
  • arr:Array - the array

Real simple. I summarize it here because, when I was looking at the docs, for whatever reason, it seemed intimidating. :-) If you want an idiom for remembering the order of the arguments so you can be one of those cool I-don't-need-no-docs programmers, I use the phrase Effectively Iterating Arrays. If you think that's lame then go find your own way to remember it and leave me alone.


This method checks to see if every element of the array is satisfied by a certain condition. You can use this method to check for the absence of nulls, negative numbers, or some other condition.

Some examples:

var myArray:Array = ["Jose", "Luis", "Carlos", "David", null, "Moises"];

// are all the names non-null?
var allPlayersValid:Boolean = myArray.every(function(e:*, i:int, a:Array) { return (e != null) });

var myArray:Array = [-5, 0, 5, 10, 15];

// are all the value positive?
var allPositive:Boolean = myArray.every(function(e:*, i:int, a:Array) { return (e >= 0) });

var myArray:Array = [-5, 0, 5, 10, 15];

// are all the values multiples of 5?
var allFactor5:Boolean = myArray.every(function(e:*, i:int, a:Array) { return (e % 5 == 0) });


This one is neat. It runs a function on every item of your array and returns you a new array with all the results. So, you can use this to run text conversions and that sort of thing.

Some examples:

var myArray:Array = ["Silvio", "tony", "MEADOW", "PAulie", "christopher"];

// correct captialization on all names
var newArray:Array =*, i:int, a:Array) { return e.charAt(0).toUpperCase + e.slice(1).toLowerCase(); });


Need to find some element that matches some criteria? This method does that. So, say I want to find out if any of the array elements matches the actual number of jellybeans in the jar:

var guesses:Array = [4234, 354345, 2342, 345643, 34634, 3452342, ...];

// did anyone guess right?
var weHaveAWinner:Boolean = myArray.some(function(e:*, i:int, a:Array) { return e == WINNING_JELLYBEAN_COUNT; });

But don't ask who did win. This method only returns a boolean result. :-)


posted by John Blanco @ 7:49 AM


Last week, my job sent me and the team out to California for a third time. Since we had to be out there about 4 days, Michele and I decided the whole family should come with me and that we should go to Disneyland!

So we did. :-)

After working nearly non-stop for three days, Michele and took a break and went to Disneyland on Friday. (Just like God, on the last day I rested.) We spent the morning getting some breakfast at Ralph's Market (in Glendale) and then, at 11, drove 45 minutes to Disneyland for some fun!

What a great place it is. I've always had the irksome feeling when I went that the parking lot would have faded paint, outdated Mickeys on the signposts, and that all-in-all I'd have this sorta "Disneyland musta been great -- back in the day" feeling. But no, not at all, as many of you may already know. The place is kept fresh, trimmed, clean and we had a blast!

Aside from eating and eating and eating, Michele and I took Cedric on all the famous rides. We went on Pirates of the Carribean, Haunted Mansion, Mr. Toad's Wild Ride, Snow White's Scary Adventure, Casey Jr., Winnie the Pooh, and -- albeit alone -- I got to go on Splash Mountain. :-)

We had lunch when we got there, then bought a Mickey balloon for Cedric. After walking around for a while and buying Cedric some Mickey ears, we decided the balloon was driving us nuts. It was windy and the balloon was huge and flew all over the place, so we stopped by Casey Jr. to see if a vendor could offer us scissors or a pin to deflate it. While I was with the vendor, Michele was mesmerized by something. When I came back a minute later, Michele asks me, "Hey. Is that Adam Sandler?"

I look up and, 5 feet away from us, I'm staring directly into Adam Sandler's dreamy eyes. Whoa! It is him! And Michele also pointed out that Kevin James was with him, too! They were going on to the Casey Jr. ride with wives and kids, and I was unable to snap a pic due to the blockading of their bodyguards and Disney personnel. However, while we were on line for Casey Jr., I was able to snap these pics as they were leaving the ride:


After taking Cedric on his first ride, we painted the rest of the park red. My favorite ride was Splash Mountain because I love getting drenched on rides. :-) Pirates was also wicked cool. Next time, Michele and I need to eat in the restaurant they have in there, too!

We played around til about 10 PM when we decided to journey back to the hotel. What a fun time! Can't wait to go to Disney World some day. :-) Here are some pics of us:

Monday, February 25, 2008

Presenting: Neopets PetPetPet Habitats!

posted by John Blanco @ 4:55 PM


Just a moment ago, Keith from Neopets finished his presentation of the game I've been working on for 3 months now. He did a great job, and I won't hold it against him that he never put the game into the cool ZOOM mode. :-)

Here it is!

Update: The first bit of media coverage can be found here. Our game is the only pic. :-)

Sunday, February 24, 2008

A Glimpse Into McCain Foreign Policy

posted by John Blanco @ 1:01 PM


We don't need more cowboy diplomacy, look at what it's got us already. Now McCain gives a glimpse of what the Bush Third Term would look like:

INDIANAPOLIS (AP) — Likely Republican presidential nominee John McCain says he doesn't look for any major political reforms in Cuba until after Fidel Castro dies, adding he hopes that's not far off.

As McCain put it during a campaign stop in Indiana Friday, "I hope he has the opportunity to meet Karl Marx very soon."

I love how religion enters into our debates, and every Republican gets a free pass -- somehow, wishing for someone's death is exactly what Jesus Would Do.

Believe what you want about communism as an economic system, but don't go putting Fidel Castro in some category of tyrannical dictator with death camps. Jesus. You wonder why America's image to the rest of the world is in the tank.

If there's a heaven and a hell, McCain took one step down with that comment -- that, I know.

Sunday, February 17, 2008

A possible election decider?

posted by John Blanco @ 3:37 PM


Can you tell me what you see in this picture? :-)

Friday, February 15, 2008

Reason #493,303,532 I Am Not A Republican

posted by John Blanco @ 6:17 AM


From Daily Kos:

At last week's Conservative Political Action Conference, Republican bloggers held forth on why their efforts at making waves in the cyberpond have so far amounted to no more than feeble ripples. What got the blame?

Erick Erickson... conceded that progressives currently enjoy an advantage over conservatives online—though he attributed it to an asymmetry in free time, since conservatives "have families because we don't abort our kids, and we have jobs because we believe in capitalism."

Uh. Yeah. Maybe, Erick, you're just a freakin idiot.

Sunday, February 10, 2008


posted by John Blanco @ 6:53 AM


Less than 9 months to go until seven years of broken government ends as we know it. Barack swept all four states yesterday and is gathering up a head of steam. Meanwhile, in Republican fantasy land, McCain is having trouble holding off Ron Paul and Uncommitted in Washington.

Americans don't want a Bush third term. Conservatives just don't even want McCain. :-)

Maine today. Virginia is a biggie on Tuesday.

But, no time for that...I have coding to do! Neopets pre-alpha due EOB Wednesday!

Wednesday, February 06, 2008

The Colorado Caucuses

posted by John Blanco @ 6:14 PM


Last night, Michele and I went to our first caucus. That is, we voted in the Democratic primary. If you're not familiar, some states do this by caucus, some by primary. It sorta seems the more populated states do primary -- but I have to say I prefer the caucus so I was pleased by the end of it. :-)

We arrived at Deer Creek Middle School early, about 6:20, 40 minutes before the "doors close" for voting. Immediately, we noticed it was PACKED. Every spot was taken, so we parked along the curb in the lot. Inside the school, there were crowds. We walked a ways, branching through this neat little school, and finally got to room #141, where our precinct was holding the Democratic caucus. (Republicans vote in separate rooms to avoid screaming and election by death match.)

The room was pretty crowded already. It seemed to be half for Hillary, half for Barack. Michele and I disagree on the nominee, so she took Cedric, I took the diaper bag, and we split up. :-) I talked with a few people while people cooed over Cedric. After about a half hour, the room was called to order, about twice as stuffed as when we entered.

If you don't know what a caucus is, it is basically where the people declare who they support, make a case for their choices to undecideds and the other side, then a re-vote occurs and delegates are apportioned.

Overall, it was great fun. The Obama side did a good job converting people. I even got my licks in when one man disagreed with Obama's energy stance and one woman disagreed with Obama's ability to help bring peace among world relations.

In the end, the final vote was 53-16 for Obama! This was even better than the state results, as Obama won easily 66-33%. :-D

OBAMA 08!!!

The Jefferson County #'s are in as well. Our "normally" conservative county saw the Democratic turnout far exceed what the Republicans could do. Chalk this up to two great candidates, or the Independents' rebuke of the Bush Administration, but it was great to see. Caucus results: 14,000 Dems to 2,000 Republicans.


With Super Tuesday done and the Dem candidates still in a virtual deadlock, the next big day is Saturday. So let's Barack and roll!

Tuesday, February 05, 2008

Time To Put The Gloves On -- SUPER TUESDAY!

posted by John Blanco @ 6:11 AM


No more of this HOPE shit, time for results. Get to the polls and let's make a statement today!

Saturday, February 02, 2008

Yes. We. Can.

posted by John Blanco @ 11:38 AM


Meet Barack

posted by John Blanco @ 5:34 AM