Gauge Component v.01

Author: Thomas Gonzalez

Well, the time has come for me to give back a little to the community from which I have learned and benefited so much. People like Ely, Doug, and too many others to list have been a source of inspiration and a repository for useful components that I have used across many projects.




This gauge component actually stems from some of my first work with the beta bits of Flex 2.0 over two years ago. For business and IP reasons I could not share this code, but now as conditions have changed I can offer this code to the community under an MIT license. It is far from a polished component, but the foundation is there. Follow this link to BrightPoint Inc. to go see the gauge in action and right click for view source.

Some of the things on the to do list will be the following, based on interest from the community and feedback.

1. ASDocs (duh...)
2. Exposing the .swc skin more easily so all the gauge parts can be swapped via MXML or at runtime.
3. Cleaning up some of the min/max label stuff (try clicking on the radio buttons at 5 and 8 o'clock.)
4. Providing the user a way to input values via scroll-wheel our mouse.

At some point I might create a commercial version of this component, but everyone is free to use this code in whichever way they see fit.

Any suggestions/comments for improvement are welcome.

Update: The newest version of this component can be found here.

 

Removing items from an Array Collection

Author: Thomas Gonzalez

Today I was troubleshooting a bug where items weren't not being removed from a Flex DataGrid the way I expected them to. What I discovered is that in this particular case my laziness in abusing the ArrayCollection was causing an unobvious (to me) bug.

Here is the simplified code that looks for a match to remove items from an ArrayCollection (yes I could use a filter, but that doesn't TRULY remove items from the ArrayCollection.source, and I can never remember the 5 lines of code I need to create one correctly.) So this was my first attempt at removing items from an ArrayCollection.

  
ac.addItem("foo1");
ac.addItem("foo2");
ac.addItem("foo3");

for each (var foo:String in ac) {
if (foo.charAt(0)=="f")
ac.removeItemAt(ac.getItemIndex(foo));
}


Now, what would you expect that trace statement to output? Personally I expected to see a big "0", but alas the ArrayCollection is not truly keeping proper indexes as iterates through its for each. Realizing that this was probably an index issue with the iterator I wrote the following which works correctly as it backs down from the last element, thus not distrupting the index as it moves backwards.

for (var i:int=ac.length-1; i>=0; i--)
{
if (ac.source[i].charAt(0)=="f")
ac.removeItemAt(i);
}

The above code does what I was intending, correctly. I guess a lesson learned on thinking that Flex did EVERYTHING for me... guess I can't be a completely lazy programmer.

 

Here is why I won't be writing native iPhone Applications: (at least not yet)



After spending about 40+ hours with the new iPhone SDK, getting up to speed on Objective-C (which is kinda cool) and modifying a few sample apps with XCode I have come to realize that while Apple makes amazing consumer products and interfaces, they fall completely short of the mark when it comes to developer tooling interfaces. Perhaps it is because I do NOT come from the land of Unix (well okay I used Unix in University, but that was over 20 years ago) and I am not a huge proponent of the command line and I prefer nice comfortable IDE's like Visual Studio or Eclipse that I don't see the magic here.

Just watch the video above to witness what kind of gyrations, both in code and UI, you need to go through to wire up a button to make a beeping noise. Windows popping up all over, connecting objects from one window to another with visual lines... opaque NIB files, etc. I am sure compared to command line C++ development this might seem like a godsend, but for someone who has spent the last 2 years developing almost exclusively with Adobe Flex, this seems like a step back into the stone ages. While I am not a huge fan of Microsoft, Visual Studio really sets the bar for a highly productive and functional IDE, Eclipse is getting better and almost there. When it comes to programming languages to create expressive and immersive UI's there is no beating flex.

I am so eager to develop immersive multi-touch applications on such an amazing device as the iPhone that I have seriously considered investing the 90 days or so I think it would take to develop a modicum of proficiency on new tooling (XCode) and language (Objective-C). But when I look at how pleasurable the experience of developing with these tools would be it looks like it would be trying to go surfing on a huge 100lb redwood board versus the 6lb epoxy short boards I prefer. While I would still be catching waves, things would feel so ponderous and slow. I thought that perhaps I am just missing it, and I needed to shift my mental paradigm to a different one so I would "get-it". After watching the video above, I am not sure that I am missing anything.

Obviously an ideal dev platform for me would be having the iPhone support Flash with Multi-touch so I could develop in flex, but I don't see that happening anytime soon. Especially considering the restrictions in the SDK. The one nuggets I did find in doing my research was that one of the SDK videos talked about the Javascript extensions they were building and the new CSS standards they were supporting. Some of the glimpses I got were:

  • Gesture support via Javascript (gestureStart, gestureEnd...)
  • CSS Animations
  • Transitions
  • Full SVG support and drawing (although not sure if that is restricted to markup or can be dynamic.)
  • Javascript access to SQLite !!! (this is huge in my mind as it could really allow online/offline apps)
The challenge I have though is that I can't find ANY documentation to support those javascript API's. I am thinking that perhaps creating web-apps with these javascript API's will afford me the ability to use more productive tooling and get the same great features. I just need to figure out how/if the SDK will allow us to support web apps running in an offline state, and if it will be possible to sell web-apps via the AppStore.

 

iPhone SDK first impressions

Author: Thomas Gonzalez

Well, I am pretty impressed with the level of effort that went into this SDK. I am on day four of just looking around, and I have yet to write a single line of code, which is very uncharacteristic of me.

The SDK is pretty polished, with custom graphics, and a deep set of well put together videos (available via Apple Developer Connection) free on iTunes. The videos were a great way to get a lay of the land.

Other than starting to get my mind around Objective C after spending the last two plus years immersed in Adobe Flex feels like a bit of a step backwards. I am not super fond of the C/C++ structures and coding paradigms, as they feel like I am having to do a bunch of unnecessary work at lower levels of abstraction that is needed. Having to deal with memory allocations and stuff like that is a bit of PIA, but perhaps it is just because I have been working in higher level languages for so long.

One interesting bit I ran across in the videos is that they have extended the javascript API for Web Kit to support the handling of multi-touch getsure events like gesturestart, gestureend, and gesturechange. But I have been unable to find any other documented API references to this, and in loading up Dashcode (their web IDE for the iPhone) I could not get any more info.

 

Learning the iPhone SDK

Author: Thomas Gonzalez

I thought it might be interesting to chronicle my learning of the iPhone SDK and building native apps for the iPhone.  I suspect that many engineers like myself will be coming from different development platforms and might find some value in learning from someone else's trials and tribulations of learning how do program for an iPhone.   

Never having programmed for the MAC before this will be a completely new experience.   At this point I don't even own an iPhone, but I see it opening up new markets, distribution channels, and most of all a new way for humans to interact with computer (smart) devices.  For these reasons I wanted to try my hand at creating a native iPhone app.   

Step 1 was downloading the SDK, which was a 2 day exercise in itself, due to glitches at the dev center site at Apple.

After downloading the SDK, I did something I rarely do, and this is start reading the docs.  Usually I just dive in, fire up an IDE and start trying to bang out an application.  In this case since, I have never programmed in objective C nor worked with the Xcode IDE I thought I would start at a higher level.

More to come if my interest does not wane and it appears that these type of posts provide value to others.