iPhone Sample: Adding UILabel programatically

July 3rd, 2009

While developing my first iPhone game App, I’m finding Interface Builder very easy to use. However, in my coding, I had the need to add a UILabel programatically. Similar to other languages/platforms I’ve worked with, handling font size, color and weight can be a little confusing.

The code below shows how to:
- Create new UILabel
- Set UILabel position (x,y) to center and size
- Set UILabel font alignment, color, font name and size
- Add UILabel to your View
- Populate UILabel with an NSString for text.

UILabel *scoreLabel = [ [UILabel alloc ] initWithFrame:CGRectMake((self.bounds.size.width / 2), 0.0, 150.0, 43.0) ];
scoreLabel.textAlignment =  UITextAlignmentCenter;
scoreLabel.textColor = [UIColor whiteColor];
scoreLabel.backgroundColor = [UIColor blackColor];
scoreLabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:(36.0)];
[self addSubview:scoreLabel];
scoreLabel.text = [NSString stringWithFormat: @"%d", score];

The score value being set is an int that I’m incrementing based on CGRectIntersectsRect of two UIImageViews. I’ll post that example soon.

If you’ve got a better, more efficient way of doing the above, please feel free to comment.

chuckstar22 Technology, iPhone

Flex, what have you done to me?

July 1st, 2009

Flex made Big changes

I woke up in Flash Professional today and realized that developing with Flex so much the past few years has finally changed the way I code Flash Platform apps. For better or worse, working with the RIA framework known as Flex has changed my approach, practice and sense of virtual space as I develop applications.

I’d say that over my 10+ year career coding Flash Platform apps, experiences, intros and animations, I’ve still spent more aggregate time in the Flash IDE environment. On stage, presenting at conferences, I have proclaimed that I am a Flash Platform switch hitter, comfortable in building apps from both sides of the Flash Platform plate. Yet the phase of my career where I’ve really grown as a developer, mostly when I was migrating from AS to AS2, and subsequently from AS2 to AS3, has been spent working with Flex.

As recently as 4 years ago (I know, that’s like 14 in technology years), I was approaching applications much differently. I’d start with layout, color, interaction, transitions, sound and all the other “cool” and “flashy” elements that made rich internet applications rich — before they were actually rich. Code came last, if at all. And there was a time where many of the projects I worked on had minimal code because working with timelines and stage-created symbols came so naturally to me.

Now, I’m completely reversed. Flipped around. A new kind of developer. My approach starts with framework, structure and logic. I think about what classes I’ll need, what approach I’ll take (MVC? Frameworks?), and what 3rd party libraries or components I need to include. And when the app is finally coded, I look at the skeleton of an interface my UI control/component-dependent approach has given me and pray there’s a good designer waiting (or even a simple, snap-in theme waiting for me on scalenine.com).

So now, back in Flash Pro for a bit, I am totally ignoring the stage. I’m avoiding doing much in the software all together, other than dragging some staple UI controls from the components panel to my Library. I jump into FlashDevelop or FlashBuilder (which I still call FlexBuilder) and write ActionScript there. When I’m ready to see my work, I say a prayer and compile, confident it will work well, but hoping it will look decent enough.

Back in the day, I would have known quite well what my app would look like before I coded it. That’s far from reality now. So is this the way I really want to be building apps? Has it made me a more seasoned and valuable developer? Probably, but it really depends on the project at hand. Has this improved performance, size, efficiency, scalability of my apps? Again, it really depends on the project at hand.

So, in conclusion, this doesn’t really matter in the grand scheme. As technology, the industry and demands have evolved, so have I. And don’t get me wrong. If you’re still perfectly comfortable and successful working in Flash Pro, that’s just as good. Developers like me need you now more than ever.

chuckstar22 Flash, Flex, Personal

My debut set for Flash on the Beach 2009

June 24th, 2009

FOTB

I’ll be making my Flash on the Beach debut this year in Brighton, UK on Sept 20-23. I just finalized my session and description (below). This will be my first time abroad/overseas in 11 years. I am very excited to make the the trip and speak to a different audience.

Tickets are still available but are guaranteed to sell out a few weeks before the event, as history indicates.

The session I’m giving is a bit updated and more intense than the one I gave at FITC just a few months ago. I’m going to dive a bit deeper into my examples (of which I had a lot of help with) and churn out some fresh takes on working with the Flash Microphone. It will be great to see you there.

Visualizing Voice: Using the Flash Microphone for advanced interaction

Flash’s microphone access, while still limited, does provide a unique way of letting our user’s interact with the applications we build and each other.

Chuck will show some exciting implementations of Flash Microphone, ranging from simple visual animations based on the Microphone’s activityLevel, to highly interactive service integrations for recording voice and sound, playing it back and streaming it.

Learn basics of microphone access and see demonstrations of popular open source Flash libraries like Merapi, Red5 and Papervision as they compliment many ways to visualize voice.

If you have a project or special technique to share, please visit getmicrophone.com.

chuckstar22 Technology

I am an iPhone developer

June 22nd, 2009

Apple picking

I am an Apple hold out no longer. After decades of resisting and even withstanding years of adoption peer pressure working/living in neighboring towns of Cupertino, I have jumped on the bandwagon. I bought my wife a gen2 iPod Touch, paid $99 to test apps, downloaded/installed the SDK, started playing with examples and have begun to tear into “Beginning iPhone Development” a.k.a. the grapefruit book (among other references).

As I initially cracked open the macbook pro (on loan) and started up xcode for the first time, the years of excuses for holding out so long rushed into my head — immediately countered by all the reasons I’m finally IN. If you’re an able and talented developer that thrives on the (potential of) mass adoption of your work/applications, you may be able to relate to the following:

My excuses for holding out so long:

1. Long and bad history working with Macs. From day 1, 20+ years ago, and especially when I was working tech support at BU getting students online in the mid 90’s, PC’s were always easier to work with, install software and customize.

2. My interest in products, especially mobile and other gadgets, is very much need driven. Having been a Windows Mobile device user for 5 years now, I already enjoyed touchscreen, wifi, excellent web browser ability, installed flash player, mp3 playback and many smart phone features. The Apple devices just didn’t seem to offer much more to me — if anything, a little less.

3. Recognizing that Apple’s initial marketing play on the iPhone was as an advanced iTunes player didn’t interest me as I am not an iTunes customer. I recognize now the brilliance in Apple positioning their device this way towards getting it mainstream adoption.

4. Apple always seemed very “closed” to me. They control everything about their products, and while I recognized it’s the ultimate effort in quality control, it carries with it this imposing and unwelcoming vibe to an innovator like me. This factor also contributes to them not including Flash player on their device, a move that would have had me interested much sooner.

So, having listed my excuses, here are the reasons I’m no longer holding out:

1. My dad has an iPhone (and so does his wife, as well as my father-in-law, so many of my friends and other very influential colleagues). The iPhone is generating so much buzz around me, it’s become too hard to ignore.

2. They are selling iPhones and iPods in Walmart. When I saw this, it really dawned on me how mainstream the product has become. Walmart = the ultimate in mainstream adoption and distribution. It means folks across the country, in all remote, un-tech locations, are buying this device — and more significantly, buying apps to load on to it.

3. My friends are building very cool things on it — and they’re having fun doing it. It seems iPhone development has lit a spark for mobile development, something I was hoping Flash Lite would do for many years. [As a career Flash developer, Flash Lite was a natural transition for me to mobile, and something a dabbled in. Like I said, if iPhone had Flash player, I'd be into both a lot more by now.] These same friends are also blogging and talking about their experiences, which is very encouraging.

4. Coding functionality like location, movement (acceleration) and touch proved to be the ultimate enticing factor. Having developed with one primary language for so long, access to new features lured me to test my abilities as a programmer by grasping another platform/language. It was time to challenge myself where the rewards could be so much more than just adding new tools (skills) to the shed.

So, I’m deep into it now. I’ve already explored so much functionality and am having a lot of fun. As usual, with any activity not involving your “day job”, identifying your own spare time can be just as much a challenge.

Thankfully, my wife has been very supportive, as usual, of me sacrificing TV-couch time with her as I pound out new and un-explored code. After all, as an iPod Touch owner, she’ll be my first and most enthusiastic customer!

Oh, and just to show I’m not totally overcome with the thought that the iPhone is the end-all be-all of mobile devices, enjoy this video…

chuckstar22 Technology, iPhone

The most fun 25 cents can buy

June 10th, 2009

For our grandparents, it was the penny arcade.
For us, and the younger generation, it’s got to be more interactive. And not just interactive, but a way to politely offend a complete stranger.
For just 25 cents, a quarter as it’s known in our United States currency, you can shoot a large volume of water at an unsuspecting patron of California’s Great America amusement park as they float by a viewing area on a water ride.

For the quarter, the coin-formed denomination representing 1/4 of a dollar, it may represent the last great use and value of this currency.

But what does it say for our younger generation to generate so much pleasure by soaking someone you likely have never met — just for the fun of it? More genuine interaction than shooting at a computer-generated alien on Xbox, I guess…

chuckstar22 Uncategorized

Fixing Snake Eyes

May 26th, 2009

Collection

After sitting in a box for 5 years (that’s 5 years too long), I finally unpacked my G.I. Joe collection to display all 75+ of them in my custom-built glass cabinet. Upon opening the box and sorting them out, I discovered about 12 of them were broken. Having a fixed bunch of them before, I thankfully had the tools, parts and knowledge to do the repair work.

My collection of 3 3/4″ Joes spans from 1982 - 1988 and includes most of my favorite characters, including Flamethrower, my all time favorite. As many of them are around 25 years old (hard to believe it), they tend to suffer from a similar problem. The black rubber band that holds the waist and torso together (called and O-ring), being made of some organic material, can rot and break. So when I opened the box of figures, here’s something of what I saw:

Broken

This wasn’t the first time I saw this. Several years earlier, I had to repair many of the figures and ordered replacement O-rings from a site called smalljoes.com. So, here are the steps I took to fix my injured G.I. Joes including one my favorites, Snake Eyes:

Unscrewed

The first step is to unscrew the back, which allows you to disassemble the figure, and take out the rotted O-ring. You put the new O-ring on the hook at the top of the legs and put the waist over it, pulling the O-ring through.

Oring

Next stretch the O-ring in the back and snap the chest piece on it. Next, carefully add in the head/neck, followed by each arm.

Together

Holding the figure together, you now tighten the screw and your done.

Salute

It takes less than a minute and should preserve your figure for several years, especially if it’s retired from active duty and sitting on your shelve.

Another great collector piece to get is the foot stand. I prefer the clear ones, but they make all colors as well. These are great for displaying the figures in on the shelf. Enjoy your collection!

Also, I should note that I recently bumped into an old friend of mine who works for Hasbro in the G.I. Joe marketing group (dream job!). I checked out the site and it’s use of Flash and sound emulates a DVD! Pretty nice effort leading up to the movie this summer. Looking forward to it!

chuckstar22 Flash, Personal, Technology

Bug Vacuum

May 25th, 2009

With 4 bugs, (3 of them live) in the bug vacuum, I thought I’d share a view inside the chamber.

You can get your very ownBug Vacuum from Amazon.

chuckstar22 Personal

The Flash Flex name game

May 21st, 2009

New name

Flex Builder has a new name. That name, you should know by now, is going to be Flash Builder.

I very badly (well, as badly as any individual possibly could who 1. was not an Adobe employee, nor 2. had anything to gain financially from a name change) wanted this back when Flex went from 1.5 to 2. You see back then Flex was a different product. It was clear that Flex was no longer the server-side, stand-a-lone, uber-code-y solution Macromedia originally positioned it to be.

At version 2, it became clear that Flex was simply a ‘top soil’ layer of rich code on top of Flash Platform that allowed more rapid, if slightly less ‘Flex’-ible designed approach to building a Flash SWF.

So now, 2 versions later, the official tool for building Flex-enriched Flash apps is now going to be called Flash Builder. I have read a lot of posts expressing concerns about how this affects the way people understand the ‘differences’ between Flash and Flex platforms.

In my opinion, the fact that people even think there are (or were) differences between Flash and Flex, or even considered them two separate ‘platforms’, is what this new product naming should solve. You see, Flash and Flex are not two different platforms. To compare the two would be like comparing a grilled cheese sandwich and a frying pan — where the sandwich is the Flash application and the frying pan is the ‘tool’ used to make it.

Flex was never an application type. Any application built using Flex Builder or leveraging the Flex framework was ultimately and always a Flash application. For years, we referred to Yahoo! Maps as a Flex application. What we all meant was it was a Flash application built with Flex.

As Sir Keith points out in his clever mock dialogue, many accomplished developers coding Flash applications have been using Flex Builder for a while — mostly due to the weak IDE environment of Flash Professional. While I would love to see a stronger coding environment with Flash Professional, I think Adobe sees this differently. Flash Professional may not get any weaker for code, but it certainly will get stronger as a creative expression tool. By making Flash Pro ever more designer friendly, Adobe can now position Flash Builder as the ultimate IDE for coding Flash applications.

The Flex framework will still be celebrated and continue to grow — especially with Flex SDK 4 on the way. We should still see even more Flex specific topics at MAX, break out conferences like 360Flex continue to flourish and see a growing knowledge base of effective framework features like data binding, advanced components and architecture. So the state of Flex is good and I believe it will have a stronger base of developers now that the tooling is well understand.

And for those concerned that Flash Builder won’t continue to attract hard core coders… Last time I checked, Flex Builder >>> now Flash Builder is still based in Eclipse. Unless that changes, the world of Java and other coders now officially have a ‘familiar’ place to build Flash applications from.

chuckstar22 Technology

33 things I learned from Danger Zone, the making of Top Gun

May 13th, 2009

Top Gun

1.) Top Gun, the movie, was based on an article called “Top Guns” discovered by Producer Jerry Bruckheimer.
2.) Jeffrey Katzenberg originally approved the writing of the movie for the studio.
3.) The writers signed on mainly so they could have a chance to fly in a jet fighter plane.
4.) The writers visited the actual Top Gun school and discovered Naval pilots have ‘their own language’.
5.) RIO = Radar Intercept Officer
6.) The writers approached the film as a sports movie, so a trophy was added for the pilots to win. There is no actual trophy in the real school.
7.) The locker room and volleyball scenes were added in so Tom Cruise, paid $1mil for the movie, would show ’some skin’.
8.) The script was originally titled “Top Guns” after the article.
9.) The accident when Goose dies was supposed to be a collision - but the Navy didn’t want that.
10.) The jetwash incident actual happened to the technical adviser’s friend. In the event of a flat spin, the RIO actually needs to wait before ejecting himself for the canopy to clear the low pressure zone. This is why Goose dies.
11.) Paramount originally didn’t like the movie. Executives wanted the movie to be more about learning how to fly the plane.
12.) Don Simpson actually begged Eisner and Katzenberg not to change the script.
13.) The movie was shelved until new management was brought into Paramount.
14.) Bruckheimer got a greenlight with a budget projecting of $14mil.
15.) Tony Scott was offered Top Gun because he had done a Saab commercial featuring a jet.
16.) The music inspired Tony Scott to go for a more “Rock n Roll in the sky” feel.
17.) The writer, Jack Epps, actually suggest Tom Cruise be cast — and wrote the script with him in mind.
18.) Tom Cruise, with a pony tail, took at test ride in a Blue Angels plane to get convinced to take the role.
19.) Val Kilmer and Tom Cruise had the same agent, and that’s how he heard of the movie.
20.) Tony Scott had to chase Val Kilmer down after the audition to get him to take the role of Ice Man.
21.) Val Kilmer and Tom Cruise did not talk to each other much off camera. Kilmer says it was to prime them both for the subtext tension and conflict between their characters.
22.) Ice Man’s coughed “bull shit”, when Maverick is explaining his maneuver, was not in the script.
23.) Michael Ironsides was unsure about his ability to pull off playing an officer, until a real Navy pilot mistook for one while on location.
24.) “Mom and Pop in Oklahoma” was an expression used for the everyday person who wouldn’t care if things weren’t detailed 100% to actual Navy specifications.
25.) The carrier scenes were shot on a real aircraft carrier, The U.S.S. Enterprise, while in service. 6,000 crewman were on board during the shooting.
26.) The real crew had been out to sea for 180 days.
27.) Director Tony Scott wrote a personal check of $25,000 so he could get the carrier’s course to change for 5 minutes to get the right lighting angle from the sun for one shot.
28.) ACM = Air Combat Maneuvering
29.) Most of the shots of the Navy planes in the sky were taken from a camera on board a Leer jet.
30.) The control tower fly by was real, and while many Navy pilots always wanted to do it, they had to draw straws to see who would get to do it.
31.) Anthony Edwards was the only actor not to get sick during the flight scenes.
32. Tony Scott’s commercial experience paid off when flipping the camera 360 degrees to capture some of the flying sequences.
33.) The film is dedicated to Art Sholl, an acclaimed stunt flier, who actually died shooting one of the flat spin sequences. Neither his plane nor his body were ever recovered.

For more Top Gun trivia, visit IMDB.
To purchase the Top Gun [Blu-ray]
featuring this awesome documentary, visit Amazon.

chuckstar22 Movies

Wish I was going to 360Flex next week

May 11th, 2009

360 Flex

At one point I was going. At one point I was speaking. Unfortunately, for me, I’m unable to do either this year. For the first time since the original 360Flex, I won’t be attending the event next week in Indy. And it just sucks for me.

This event is the best, in my opinion, for all levels of Flex developers. You simply don’t have direct and personal access to so many talented presenters and session as you do with 360Flex. It’s the lowest cost event, by far, and the organizers, Tom and John, work very hard to keep it humble and simple.

They’ve done a great job profiling the speakers and sessions this year. Here’s a link to the schedule, and you’ll see some amazing names and topics being featured.

My boy Wes Leonardo, from Ribbit, will be presenting some cool AIR stuff. Also, if I were going, I would not miss Joe Johnston’s FLEXperience session, all about UX in Flex!

I’ll miss hanging with everyone, but I’m sure it’ll be an awesome event.
And if you’re not going, and CAN go, you owe it to me to go to http://360flex.eventbrite.com/ NOW and register.

Have a great time and good luck with what I’m sure will be another incredible event for the community!

chuckstar22 Flex