as3

QuickTip: Notifications in Cocoa-touch

Posted in as3, cocoa touch, iphone, objective c on March 12th, 2009 by admin – 6 Comments

A very handy thing in cocoa is the use of notifications.
Although it doesn’t work exactly the same as Events in AS3, it can be used for the same principal.
There are 3 functions you need to keep in mind.

- (void)addObserver:(id)notificationObserver selector:(SEL)notificationSelector name:(NSString *)notificationName object:(id)notificationSender
- (void)postNotificationName:(NSString *)notificationName object:(id)notificationSender userInfo:(NSDictionary *)userInfo
- (void)removeObserver:(id)notificationObserver name:(NSString *)notificationName object:(id)notificationSender

read more »

AS3 to Cocoa Touch: MovieClip vs UIView

Posted in as3, cocoa touch, iphone, objective c on February 12th, 2009 by admin – 8 Comments

UIView vs Movieclip.

It’s true that the UIView object has comparisons with the Movieclip object in actionscript.
But not everything is the same. I’m going to discuss a couple of examples that you would do with a movieclip and show you how to can achieve the same result in objective-c with the UIView object.
But first a couple of statements about the UIView / Movieclip object:

Movieclip Question UIView
The object is a container for view/display objects
You can draw into the view/display object
You can animate the object directly
Accessing view through id

read more »

AS3 to Cocoa touch: JSON (Part 2: send JSON)

Posted in as3, cocoa touch, iphone, objective c on January 5th, 2009 by admin – 8 Comments

So for part 2 of my tutorial about json. We are going to use json encoded data to transfer over http from your application to the backend server. There are some things you have to keep in mind if you encode json in cocoa touch using the json framework (which I’ve used in the previous tutorial). But we will go deeper on that subject later on.

So for this part of the tutorial my usercase will be. Send a couple of Person objects over http using json to encode and get an xml in return which lists the Person objects in xml form. This maybe not a practical usercase but it illustrates the point of sending json over http. read more »

AS3 to Cocoa touch: JSON (Part 1: load json)

Posted in as3, cocoa touch, iphone, objective c on December 24th, 2008 by admin – 9 Comments

So in this tutorial I’m going to discuss what would be a possible way to  transfer your data from a backend to your iphone. I have 2 primary things I have in mind doing this what are very important to me. It must be easy to implement (in the backend as well as in objective-c), And I need a format that is accessible from many program languages / approaches.
So from that point on I stumbled upon the use of JSON. It’s very easy in use, support for many languages (http://json.org). My Actionscript mind would always put amf in favor since its very well supported in actionscript and the flash player. As well as the backend side of the story ( fluorine, amfphp, weborb, blazeds, livecycle, ..).

The usercase that I came in contact with the most was, get something out of a database with php convert it to amf with amfphp or weborb and send it over to flash. So that’s the usercase I want to take as an example to do the comparison. So what is my setup ?

read more »

AS3 to Cocoa touch: XML

Posted in as3, cocoa touch, iphone, objective c on December 18th, 2008 by admin – 9 Comments

For this tutorial were going to discus XML Parsing. I’m not totally fond of the xml functionality’s in objective c. I use XML all the time in actionscript because its so easy and powerfull with E4X.  Although there are some open source initiatives for xml parsing. I find it hard to implement them into my projects so I keep it with the standard XML class provided by the cocoa touch framework. So we NSXMLParser, and.. oh wait that’s the only one. NSXMLDocument, NSXMLElement, .. won’t work on the iphone, I didn’t test it but what I have read on the forums about it will work in the iphone simulator but not on the iphone itself. ( by the way if someone knows a great/simple api for xml parsing on the iphone let me know ;-) )

So for this tutorial we are going to stick with the NSXMLParser class.
Actually the NSXMLParser isn’t so bad at all if you start working with it.
The basic idea behind the NSXMLParser class is that it iterates through every element in your XML.
And it uses a Delegate to invoke the methods needed but that will become more clear when we dive into it.

So our user story will be: we have an XML of a couple of person with there name and an attribute with there age, so you can simple use the classes from my previous examples. read more »