The Nordhagen

  • Home
  • LazyFallback
  • BindMax
  • Olog
  • About me
Browsing: / Home
Shortlink

The case for BindMax for data binding

By Øyvind on Thursday, January 19, 2012 in Adobe Flash, BindLite, BindMax, Freebies


I made a couple of small updates to BindMax today (read about them at the bottom of the post). I’ve been using it myself for several projects and it has easily become one of my favorite self-made tools. It’s been been rock solid and serving me very well and I feel like more people should be using it. But maybe you don’t know what it improves upon? Let me help you.

Data binding is essentially tha synchonization of values, typically between the model and the views (read more here. For Flex applications data binding is typically accomplished with the [Bindable] compiler meta tag. For pure AS3 applications it’s been a roll-your-own world and some even use [Bindable] here as well. This is just wrong.

These are the reasons why BindMax is better than [Bindable]:

  • Mobile loving
    Building mobile apps with AIR? Then you know it’s all about squeezing file size out and performace in. BindMax is an implementation of the observer pattern, which is a much simpler structure than the Flash Event bus. In fact it’s beautiful minimalism compared the Events. Smaller file size, better performance.
  • Speed!
    For primitive data types BindMax is generally 3x faster than [Bindable]. Performance with complex data types obviously depends on how fast your compare functions are, if you have any. Without them, complex data types propagate just as fast as the primitve ones. The speed tests are included with the source so check for yourself!
  • Early type checking
    A data binding is usually defined early in the application run cycle. When that happens, BindMax will evaluate each attempt to bind a property or setter against the data type of the binding and throw an error if the data types don’t match. With [Bindable], you get no errors until the target property/setter for that binding is used. For a property that is used only rarely, you may never even see that error until the client/user stumbles over that rare use case and tells you.
  • Boot time property/getter/setter name validation on both sides of data binding
    Just as with type checking, BindMax validates that that the names match between the property or setter you bind a property or getter to.
  • Easy custom compare functions for complex and custom data types
    Primitive data type values like numbers and strings are easy to compare. Complex data types like arrays, dictionaries and custom objects require special handling. For this scenario, BindMax provides setCompareFunction which lets you pass it a function reference to a custom function that takes two instances of the same class and returns true if they are equal.
  • Optional automatic binding disposal
    To play nice with the garbage collector, BindMax lets you turn on automatic disposal of bindings which are no longer in use. When the last target for a binding is removed, BindMax will dispose of it.
  • Previous value retrieval
    BindMax stores the last value of each binding so you can retrieve it with retrieveLast if for comparison with the new value. The typical use case for this functionality is an animated image gallery where animation direction is determined based on image index vs previous image index. I’m sure you can think of several others.
  • Powerful reset function
    With the reset function, you can reset any or all of the bound properties to their default values (value of the property when the binding was defined). A quick call to reset followed by propagateAll will effectively reset you application.
  • Propagation forcing
    There are times when checking if a value is in fact changed simply doesn’t make sense. Then you wanna be sure that a value spreads to you application each time it is set, even if hasn’t changed. BindMax lets you override change detection on a per-update or per-property basis.

So go get it! At Google Code

NOTE: From now on I will be talking mostly about BindMax instead of it’s little brother BindLite. I’m leaving BindLite in the source in case someone finds it useful, but BindMax is much more verastile by not being an all static access class.

I’ve also updated the BindMax tutorial

The updates I made were the following:

  • Added reset all functionality when calling reset without arguments
  • Added setForcedPropagation function
  • Added propagateAll function
  • Removed outdated example project
Share this on: Mixx Delicious Digg Facebook Twitter
Shortlink

Drawing a motherf**king dashed line in AS3

By Øyvind on Wednesday, December 14, 2011 in Adobe Flash, Freebies, Problems & Solutions

I needed to draw a dashed line in AS3. I thought it would be easy, but I thought “hey, that one’s already been covered”, expecting that if I could find some ready-made class or lib that would do the job, I might even get some extra benefits. I went on this great interweb page called Google and I searched for “Dashed Line AS3″.

I was disappointed at all the feeble attempts at doing something so simple, so after a couple of attempts i did it myself. I even threw in the added benefit of making it able to draw itself between two points you supply it. I was expecting something extra so I imagine you did too.

Here ya’ go:

DashedLine.as

PS: Damn, that drop shadow Mac OS X includes in window screenshots is really something.

Share this on: Mixx Delicious Digg Facebook Twitter
Shortlink

FIX: Garmin sync hangs at 50%

By Øyvind on Thursday, December 1, 2011 in Gadgets


Completely unrelated post if you’re used to the usual ActionScript stuff I’m posting, but this has been bothering me for so long. I just want to put this out there now that I finally found a solution.

If you’re like me in that you exercise and you track your workouts with a Garmin device, there’s a chance that you’ve experienced the situation where the sync will hang about halfway through.

Why?

What seems to happen is that the Garmin Communicator plug-in is able to read the TCX-files off the device and onto disk (that’s the first 50% of the process), but crashes when it tries to upload the files to Gamin Connect, Dailymile, Runkeeper, Endomondo or any other site that uses the plug-in for sync with Garmin devices. There’s actually one progress bar for each of these steps on Garmin Connect, so the above image would not be completely accurate, the first bar would reach 100% and then it hangs.

One solution..if you can call it that

My previous solution would be to force quit the plug-in in Activity Monitor and try again until it finally worked (often as many as 6-8 attempts). I sync my runs to each of the four afformented websites (if only my friends could agree on the same site), so you can quickly see that this process becomes tedious.

Better solution: Clear the cache

What seems to be the problem is that the last TCX file that was synced is still in the browser cache and is somehow able to confuse to plug-in, because the solution to the problem is rather simple; clear your browser’s cache between each sync. This has proven to be a stable workaround for me for a while.

A note on Garmin Support

I’ve tried contacting Garmin Support several times about this, but no replies yet. The problem is even mentioned several places on the Garmin Support forums, but I doubt Garmin moderates or even monitors their own forum. An official response has yet to be made at least. I have a love-hate realationship with Garmin because I think they make hands down the best GPS HR monitors (with some exceptions), but at the same time their support is appalling and sadly I’m far from the only one who thinks so.

Share this on: Mixx Delicious Digg Facebook Twitter
1 2 … 25 Next »

Search

Twitter

    Flickr

    Friends

    • Ballesparket
    • Christine Nygaard-Andersen
    • Haje’s Writings (Haje Jan Kamps)
    • Hastalasiesta (Martin Jacobsen)
    • Knut Nordhagen
    • Martin Jacobsen
    • Photocritic (Haje Jan Kamps)
    • The Montreal Twang (Thomas Wangsmo)

    Copyright © 2012 The Nordhagen.

    Powered by WordPress and News.