iPhone on holidays

Welcome back everybody!
I just want to share with you my little experience I had with the iPhone sdk during my summer holidays.

This year I haven’t spent my holidays on the beach, like usual, because I just bought home and so I had to put up everything… that’s why I decided to devote some of the free time to try out objective-c. I wanted to make something for the iphone since I bought it in March in NYC but I never had the free time to do that..

First of all I had to buy a new Mac-mini because the iphone sdk is not supported on my old mac-mini ppc. Then I had to subscribe to the developer program for $99 because otherwise I was unable to test applications on my iphone, but only on the simulator (cool, I have to pay to install my own applications on my iphone!).

Well, after reading a bit the documentation, watching some video tutorials and looking at example code I started with my first application. What I wanted to do was a simple SMS application to show sms received, sent and a simple search. A very simple app but for me better than the limited built-in iphone sms application.

After a couple of days I reached my goal, but not without troubles. There’s nothing inside the iphone documentation about the SMS system.

Afterward using an “UPDATE” sqlite query I was getting an error: “SQL error: no such function: read”, and obviously there was nothing in the doc explaining this. Only after half a day I discovered that I had to create a C method and use sqlite_create_function in order to bypass that error:
const char *fn_name = "read"; sqlite3_create_function(database, fn_name, 1, SQLITE_INTEGER, nil, sqlite_fn_read, nil, nil);
Now that everything with the db was fine I had to google a bit in order to find a way to implements features like “reply”, “forward” or “call” (basic features in a telephone, but not covered in the iphone sdk documentation).

Finally, after a long debug and Instruments session to find leaks ( I must admit xcode has some powerful tools for debugging and inpect apps) I installed my first application on my own iphone.

And big big surprise!! On the iphone my application is unable to mark messages as read and delete messages too!
In other words it is unable to write into the sms.db!

And Why?
That’s because a beautiful sandbox which does not allow applications to write outside their scope! Oh, cool! That’s correct, but in this case you, Apple, must give me an API which wraps those features!
They gave an SDK for developing on a mobile phone but they don’t grant access to any of the telephone features?!?

Awesome stuff from Aviary

It has been a lot of time since we started working on Aviary.

During the last months, a lot of guys have helped us with beta testing some of the tools we are working on, and they have been able to produce really awesome stuff!

I collected a bunch of images from the Aviary website to show you the power of the tools. Those images does not rappresent the best, but they are just a collection of good compositions made with Peacock, Phoenix and Raven (respectively a Computer algorithm-based pattern generator, an Image editor and a Vector editor ).

Here is the list of images I collected, grouped by tool. You can click on each image to go the to Aviary page and (if you have an account) start playing with it.

Phoenix

Phoenix is the Image Editor. It is quite similar to Photoshop, and has some advanced features for image editing.

Peacock

Peacock is a Computer algorithm-based pattern generator. Basically you generate an image assembling nodes that accept an input and produce an output. Combining this nodes may produce awesome stuff, and Peacock can be used for many purposes like advanced retouching effects or the creation of complex reusable filters (like the one used to transform a fish into bricks).

Raven

Raven is the Vector Editor. Actually it is in alpha stage but we are going to release a major update that adds really powerful tools.

From each image you can gather many useful information: the list of revision, the list of derivates, the list of sources, and other useful stuff. Each composition made with Aviary can be edited by any user to create a new revision, or can be used as a source for a brand new image. That makes some tools really useful an powerful: for instance you can build reusable filters in Peacock and use them on your Phoenix images.

There is much more on the Aviary website, and more images are added day by day.

I really suggest you to give Aviary a try; we are working hard to be able to go public soon, and outstanding new features will come in the near future. Post here if u want an invitation!

Have a good day 😉

AMFPHP issue referencing ByteArray

Recently I made some test in AMFPHP sending an retrieving ByteArray to be stored in a mysql blob field.

But suddenly I encounter a problem when I was trying to return an array of ByteArrays and I could not find out the reason flash continued to show me this error:

The php file which was generating this error was:

class Service
{
public function getArray( )
{
$GLOBALS['amfphp']['encoding'] = 'amf3';
$a = new ByteArray("\x00\x10this is a string");
$b = new ByteArray("\x00\x16this is another string");
$c = $a;
return array( $a, $b, $c );
}
}

While the Actionscript test class was:

package
{
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import flash.net.Responder;
import flash.utils.ByteArray;

public class test extends Sprite
{
private var nc: NetConnection;
private var rsp: Responder;

public function test()
{
rsp = new Responder( onResult, null );
nc = new NetConnection();
nc.objectEncoding = ObjectEncoding.AMF3;
nc.connect( "http://localhost/amfphp/trunk/gateway.php" );
nc.call( "test.bytearray.Service.getArray", rsp );
}

private function onResult( e: * ): void
{
if ( e is Array )
{
for each ( var b: ByteArray in( e as Array ) )
{
trace( 'reading bytearray...' );
b.position = 0;
trace( b.readUTF() );
}
}
}
}
}


After some investigation I found that the error was into the AMFSerializer.php file in the writeAmf3ByteArray method which doesn’t reference correctly the bytearray objects.

Thus I made a little modification and after that I succeeded to retrieve correctly the bytearray list ( with the 3rd element as reference of the first one ).

Here you can download the patch file, if you want to test the modification ( at your own risk 🙂 ). The patch has been created using the last svn version of amfphp and you can apply the patch with the following command:
patch -p0 -i bytearray.patch

Expressions evaluation at (almost) native speed

Finally I found a bit of time this weekend to do some other tests with expressions evaluation.

The results are pretty interesting, even if obvious from some point of view. I took the ExpressionEvaluator I wrote as example for the first post about this topic, and then I edited a bit the code adding just in time AS Bytecode compilation.
Thanks to that, expressions evaluation is much more fast and always safe because it runs in its own ApplicationDomain.

You can download the sources here, that includes the edited code and a test file. The test file runs 1 milion of iterations and may hang your browser or at worst case your system. Reduce the value of the ITERATIONS constant if you are not sure about the power of you machine.

If you want to read a bit more details about that, click on the link below to continue reading.

Continue reading

Use Away 3D man …

… or at least give it a try!

Working on Aviary I had the plesure to meet Alexander and Fabrice, the creator and one of the actual maintainers of Away 3D engine.

As you might known, we are using Away 3D for Hummingbird, and I had the plesure (yes, another :P) to give a look at the code an work in touch with the developers. I have to admit that Away 3D is really good!

I’m far to be the best person to suggest one framework over the others, but what I can do is tell you why I think Away 3D is (at least) worth a try, even if you are already working with Papervision 3D or the other engines. The first thing to know is that both the projects comes from the same branch – they have been splitted a few years ago (maybe just an year but I’m not sure) and then they followed two different paths. During my quick and basic experience with Away 3D I see that it has a real clean and powerful API (you have animation for instance or really good materials), good documentation and tutorials (see Fabrice‘s blog for a bunch of them!), more precise a quick rendering. And part of the new Papervision 3D 2.0 code is inspired by that library.

The various libraries outta there are for different purposes, and probably are taking (or will take) different directions (ie: see Alternativa 3D for instance, which seems well suited for games). But trying many of them instead focusing only on the most famous one is a really good thing – many users comes from PV3D for instance and are really happy about Away!

Don’t take my assumptions as gold: this is what I think after just a bit of playing 😉

AS3 tour, last stop Milan

Just come back from the big Apple and discovered that Adobe as3tour, presented by Colin Moock, will be in Italy on Moday 23rd of June, and more precisely in Milan at the Atathotel Executive.

Also, this will be the last stop of the tour! So don’t miss it if you live near Milan, like me!

The course teaches object-oriented programming fundamentals in
ActionScript 3.0. it is designed for Flash users with beginner to
intermediate programming skills (*NOT* advanced programmers). the target
audience should have:
* familarity with the Flash authoring tool
* basic knowledge of variables and functions
* little or no experience with object oriented programming

topics covered include object-oriented programming, classes, objects,
variables, methods, packages, event handling, displaying things on
screen, and compiling and running programs.

Anyway, dont miss the beer(s) at the end of the meeting!! 🙂