Tiffany B. Brown

A web log about web development and internet culture with frequent detours into other stuff.

Clearing LoadVars() in ActionScript

The LoadVars() object is a funny thing. It’s basically a bucket for variables that you’d like to load into and send from an SWF file, as well as any methods and event handlers you invoke.

LoadVars() can be problematic, however, if you ever find yourself reusing the same object for repeated load() or sendAndLoad() operations. As explained in the ActionScript 2.0 Language Reference:

Downloads variables from the specified URL, parses the variable data, and places the resulting variables in my_lv. Any properties in my_lv with the same names as downloaded variables are overwritten. Any properties in my_lv with different names than downloaded variables are not deleted.

In other words, if you continue reusing the same LoadVars() object, you’re going to have more data floating around than you may need at a time. Let’s take a look.

First we’ll request a file containing variables with a load() operation.

var bucket:LoadVars = new LoadVars();
bucket.load('vars.txt');

The file vars.txt looks like this:

content1=The+quick+brown+fox&content2=Jumps+over+the&content3=lazy+dog.

Each variable (that bit to the left of the = sign) becomes a property of your LoadVars object (bucket), and each variable’s value becomes a the value for that property.

If we iterate through bucket using a for loop when the variables are loaded, we’ll see that content1, content2, and content3 are now properties of bucket.

bucket.onLoad = function(){
     for(i in bucket){  trace(i+': '+bucket[i]+”\n”); }
}

Outputs:

content1: The quick brown fox
content2: Jumps over the
content3: lazy dog.
onLoad: [type Function]

Now let’s say we need to send a variable to our server and retrieve some new results. We’ll do a sendAndLoad() operation, and store the results in the same bucket object.

bucket.username = 'cleophus';
bucket.sendAndLoad('morevars.txt',bucket,"POST");

The data received from morevars.txt looks like this:

firstname=Dwayne&lastname=Wayne&major=math

If we execute another for loop, once the data is loaded, we’ll now see that there are more properties stored in LoadVars().

bucket.onLoad = function(){
     for(i in bucket){  trace(i+': '+bucket[i]+”\n”); }
}

Now outputs:

content1: The quick brown fox
content2: Jumps over the
content3: lazy dog.
username: cleophus
firstname: Dwayne
lastname: Wayne
major: math
onLoad: [type Function]

Any more load or sendAndLoad operations will only add properties to the object unless you overwrite them — or delete them.

Before deleting anything from your LoadVars object, however, copy the properties and values to another variable. Arrays and objects are a good fit here. You can create an array that only copies the variable-value pairs that you need to keep, then delete each variable from the LoadVars object, emptying it for reuse.

function turnVarsToArray(sendAndLoadObj:LoadVars):Array{
	var loadVarsArr:Array = new Array();
	for(var e in sendAndLoadObj){
		if( typeof(sendAndLoadObj[e]) !== ‘function’){
			var pair:Object = {vari:e, val:sendAndLoadObj[e]};
			loadVarsArr.push(pair);
		}
          delete e;
	}
	return loadVarsArr;
}

Mike Gravel vs. Obama: “Juneau What? Anchorage What?”

I might just vote for him. He says he’s a Libertarian, but he’s also quite progressive and I agree with him on many issues. Anyone who doesn’t take himself so seriously that he will learn and do the Soulja Boy in a campaign video has to be at least a little bit cool, right?

Debugging tip: “Disallowed Key Character” error in CodeIgniter

After 6 hours of massive anxiety, stress, near tears, one pound on my desk, and some hair pulling, I tracked down the source of a nagging Disallowed Key Character error that I received while using CodeIgniter: an extra line break.

The line feed (LF) and carriage return (CR) characters (and their hex code equivalents (%0D and %0A) are forbidden in CodeIgniter’s framework. The hard part is tracking down exactly where that extra line break character lives.

In my case, there was an extra line of blank, barren, not-all-that-obvious white space at the very, very end of one of my controller files, just after the closing ?>.

Related:

Who do you trust more: Corporations or Government?

This post takes the long road. If you don’t want to take the long road, skip the train of thought and get to the point.

In one of my moments of Random Thoughtitude, I was thinking about what my ideal country would look like. My first thought was infrastructure. I want a government that adequately funds and maintains a viable, nation-wide mass transit system and mandates bike lanes on every road. I want an educational system that actually teaches kids.

My next thought was: and what if our telecommunications infrastructure was owned and maintained by the government? What if our cable wires, our radio, our phone lines, and — the thing that sparked my original thought — our Internet were seen as massive public works projects on the order of sewers and roads?

Corporations would then compete in other ways. They might, for example, offer special content and charge for access to it. Or they might sell the hardware to connect to this otherwise national infrastructure.

Telecommunications, and the Internet in particular, has become this sort of basic, critical business commodity that is key to economic growth. But the corporations that run them are either too concerned with profits or really don’t have enough capital to upgrade their networks.

And we wouldn’t have this ‘Net Neutrality issue of corporations wanting to charge more or limit the flow of certain forms of data because boo-frickin-hoo, they don’t want to invest in their systems. Corporations are, after all, legally-bound to pursue profit. Their decisions must be made — for the bottom line, not the common good. Our government, on the other hand, would really have to treat all data the same and invest in our systems because we were all paying for it with our tax dollars.

Makes perfect sense, right?

Or does it? I thought some more and remembered that China controls its Internet infrastructure. And they have a few issues with censorship. Ditto Iran.

Our own government also has issues with freedom and privacy. Maybe handing them the keys to the Internet car would not be such a good idea after all.

I realized then that this is a pretty big conundrum. I wholeheartedly believe that corporations are evil, heartless, parasites who are incapable of doing The Right Thing unless it will make money. But I also believe the U.S. government is more concerned with maintaining power, control, and protecting their own personal safety and wealth than with building a just, free, and fair society.

So the question becomes: Who do you trust more? Corporations or Government?

And as importantly, what entities do you trust or would you trust? What does your ideal nation look like?

VoIP links: Skype launches mobile version; Zfone releases beta

Yeah, what Baratunde said.

All that needs to be said about the verdict in the Sean Bell case.
The NYPD things black people are made of Kevlar.

Atlanta, GA: Modern Atlanta 2008

Modernistas, get giddy. Next month, Atlanta’s modern architecture and design will be showcased as a part of “Modern Atlanta 2008: Design Is Human.”

Highlights of Design Is Human include a wine tasting at Poliform SWITCH, the Belgium Design & Fashion Event for Darfur, and a modern home tour.

Ticket prices vary. Many events are free. More information is available at the Modern Atlanta web site (designed and developed by some ultra-groovy folks).

Event details

  • When: May 6 - 11, 2008
  • Where: Various locations across the City of Atlanta
  • How much?
    • Most parties are $20, though some are free (and all are free with a home tour ticket)
    • Home Tour: $30 for one day pass; $50 for weekend pass
    • Fashion show: $60

Post-Sex 2.0 Fun

Cross-posted to the Sex 2.0 site

If the post-Sex 2.0 fetish and swing party isn’t your thing, but you still want to have a sex-centric Saturday night, I’ve got some options for you.

Atlanta Film Festival

These screenings and panels take place Saturday, April 12. Admission is $10.

Will you be here Sunday too? Groovy. I’ve got some more goodies for you:

Strip clubs

More into strip clubs? All clubs listed below feature female dancers except for the Coronet Club and Swinging Richards. I have only been to one (Strokers). Information below is based on local reputation and/or the venue’s web site. (For your information: Atlanta strip clubs are all nude, but you can’t touch the dancers.)

Swinging Richards
1400 Northside Dr., Atlanta. Gay male crowd. Women aren’t banned, but bridal shower and raucous girls night out types of groups are. Please respect the space.
Coronet Club
5275-B Roswell Rd, Atlanta. All male dancers for a female clientele.
The Cheetah
887 Spring Street, Atlanta. The Cheetah is a ‘Gentleman’s Club‘ geared toward the business set. What does that mean? No poles. (Boo!) Rumor is that their upscale restaurant Alluvia is pretty good. Mostly white dancers.
Magic City
241 Forsyth St SW, Atlanta. Word is that Magic City is the premier strip club featuring black dancers. Ludacris filmed his ‘P-Poppin’ video here. The crowd tends towards ‘baller’ (as well as the ‘I just cashed my check so I can fake it’ set). I also hear the table dances and cover charge are higher than most places. Music = hip-hop.
Strokers
1353 Brockett Rd, Clarkston. It’s in a strip mall. Crowd: hip-hop. Dancers? Mostly black. Not as heavy on the eye-candy as Magic City is rumored to be. Dances are $10. Cover is $10. Music? All crunk.
Pink Pony
1837 Corporate Blvd., Atlanta, GA. Kind of legendary. I hear it’s fun. Dancers are mostly white.

All sexed out? (Impossible!)

Will you be all-sexed out by conference end? Here are some other options: