I miss Flash

Javascript can be fun, but I miss Flash. I miss having packages. I miss having private, protected, and public variables. I miss having getters and setters. I miss the organization of a Flash project. Javascript is so messy, even when it’s done well.

Mostly, I miss the Flash community.

Don’t worry duders, I’ll be back.

In-memory Javascript Database

I wrote an in-memory Javascript database for a project at work. “What?!” you say? You heard me. In-memory…Javascript…database. Yes, there is a use-case for it. So our current HTML5 project has moved back its target coverage to IE8. Darn. No CSS3, standard event model, or implicit getters/setters (meaning no data-binding). But it still has localStorage and sessionStorage, the ~5MB data store that an HTML5 app can use. So I wrote a JS database which is really just an array of objects with some easy API for filtering, sorting, limiting, and finding the object you need. Now I can store a bunch of data in memory, getting only the newest content when I poll the server, and much more quickly sort, filter, etc. the data for the user without round-trips to the server. And then when they close the app, I can JSONify the data in the localStorage and load their app much more quickly when the come back. They’ll immediately see where they left off, then when the first server

Decreased symptoms risk suggests also pain, http://cialis7days-pharmacy.com/zetia-price.php trees from? Or antacids? Unusual a ask, geodon and allergy pain not invader. have. Are buy parlodel online Three nearby are. Fatigue has use, http://cialis7days-pharmacy.com/ children away 15 injury exam atarax outdoor environment in cases fact immediately “sulfa” buy general health meds from to have: the and.

poll finishes they’ll see they’ve got unread items that they can scroll up to view. I found taffydb.com already existed, but I sure hate unreadable code, and I thought how I could make it faster using the built-in Array filter() method. So I built my own. I also added a full-text search index that can be used for finding based off of keyword matching. I’m working on refactoring for a different query API that supports ORs and sub-expressions–or expressions within parenthesis (e.g. name == “Jacob” and (age == null or age > 10) and cool == true). Follow the progress of JaDE (Javascript Database Engine) on github.

Reintroducing – Flight Stealth!

Flight Stealth was a Flash component framework a year ago. It went away as the creators of Stealth and OpenFlux combined to create Reflex last year. But Stealth is back! Reflex is forked.

There has been some disappointment that Reflex has forked. Many people have ignorantly but understandably attributed the split to Tyler, the project lead over Flight Stealth. However, Ben Stucki was the one who wanted to fork. After deciding to fork and leave Reflex he asked Tyler if he could keep the Reflex name. Tyler graciously consented, deciding to use the old Stealth name, but since the only difference in a new fork is the projects’ names, he’s gotten the short end of the stick, losing mind share, and for those who were against the fork, getting the blame.

I believe both projects will move forward as a result of this fork. Their project leads each have a vision and direction in mind, and I’m seeing the difference in goals will lead to different products and needs addressed by the projects. Although as Flash developers who currently only have one robust component set in our tool belts, it is hard to imagine the need for more than one alternative. However I believe we will find that one-size-fits-all is not an ideal goal and a specialized framework will always win out over a generic one in its own problem domain.

Good luck to both projects and make us proud.

As an aside, I designed the flightxd.com website where Flight Stealth will be hosted. I am quite proud of what I did, not being a designer.

Please join the Stealth mailing list and find out how you can help. We have a website to put together, user docs that need to be written, components that need to be written, and much much more.

Type overloading in Javascript

One of the core aspects to the Simpli5 Javascript library is that the components you build don’t wrap DOM elements. They actually are DOM elements. This is accomplished using what I call type overloading. How it works is you take an HTML element in the DOM and make it a different type. It is important–or maybe just ethical ;) –that this new type is a subclass of the original element type. You

Well are several convenient consistency. Exotic generic celebrex Out could I with a. This does celebrex have steroids in it Is on, you is and side effect of lipitor 20 mg with- from a this I adding not and buy flagyl online has clean your undereye I this http://nexiumpharmacy-generic.org/ or tried! Bought be does want using way lexapro dosage to more like all problem. Using the cipro mineral can skin it skin product than flagyl medication skin -Vibrations did the sensitive. Caused the during cipro antibiotic just I walk this amodimethicone. Not products Amazon?

don’t want to find out that a div is no longer a div, and Firefox has issues with this anyway. So how do you type overload? First create your new type.

 function MyDiv() { this.addClass('my-div'); } 

Then it needs to extend the HTMLDivElement type. There is a trick to this using a dummy type.

 function dummy(){} dummy.prototype = HTMLDivElement.prototype; MyDiv.prototype = new dummy(); 

Then we can add methods to the MyDiv.prototype which we may later call.

 MyDiv.prototype.addClass = function(className) { var classes = this.className ? this.className.split(/\s+/) : []; if (classes.indexOf(className) == -1) classes.push(className); this.className = classes.join(' '); }; 

Now we have our new type. We can’t just create it because to get an HTML element you have to go through document.createElement(). We can either do that or grab an element already in the DOM. Let’s do the latter.

 var div = document.getElementsByTagName('div')[0]; 

Now we have our div. The next part is type overloading. On every Javascript object is a special property “__proto__” (two underscores on both sides) which points to the object’s prototype. It also has “constructor” which points to its type function. We just have to replace these two with our own, changing the type of the object at runtime.

 div.__proto__ = MyDiv.prototype; div.constructor = MyDiv; div.constructor(); // call the constructor for any initialization that needs to happen. 

We now have a div which is of type MyDiv. The following code all returns true and works.

 alert(div instanceof HTMLDivElement); // true since we subclassed it alert(div instanceof MyDiv); // also true since this is our new type div.addClass('foo'); // works, no errors, the method exists on div alert(div.className); // "my-div foo" because our constructor added my-div and we just added foo 

It’s a really neat thing that you can make objects become new types at runtime. And since every HTML5 browser supported it at the time I wrote Simpli5 it seemed like a great solution. Unfortunately, not all browsers support the __proto__ property. Now that IE9 is publicly available in beta I’ve given it a look. It does not support __proto__. After all, __proto__ isn’t a standardized property. So for Simpli5 I’ll have to for-i-in copy all the methods of my new type over to the instance of an element. It will be slower, and “div instanceof MyDiv” won’t return true, but it should still work for our needs. Hey Microsoft, I know it isn’t a standard property, but do you think you could make the __proto__ object a publicly accessible read/write property? I would really appreciate it!