Thoughts about flash on the iPhone

I didn’t have the chance yet to try out childcare level 3 unit 1 assignment help Flash CS5, but I’m still a bit concerned about the new feature that makes users able to compile their own application into valid iPhone apps.

Things look really good if you look at the examples and if you talk with the people that already had the chance to try this feature out. But I must remember that usually the excitement for a new – and let’s say outstanding – feature usually cannot guarantee the final result to be acceptable. I fear that this feature might evolve the same – bad – way as Alchemy did: they started with a promising project that then felt down to a side project because many users shown that it was possible to achieve the same or better results by just using plain AS.

A few weeks ago I started spending my free time on experimenting with generating a valid iPhone app from a SWF file. I didn’t know anything about the fact that the Adobe would have put the same feature in Flash CS5.
My approach wasn’t too sophisticated: basically, as long as I didn’t have so much time to spend on writing a full binary converter, I was http://pikselartphoto.com/phd-thesis-cooperative-learning/ phd thesis cooperative learning parsing the SWF and then generating static Objective-C/C++ (well mostly C++ and I’ve used Objective-C as glue where strictly required) code that then was need help with my dissertation compiled by Xcode to a working iPhone application.

I stopped once I figured out that Adobe was going to promote a similar thing (even if rxmeds hub order viagra super active online their approach is better and probably more powerful), but I had time to figure out a few issues that they may encounter (or maybe they already encountered):

  • Generated applications are thesis writer help really big in size, mostly because there is a lot of glue code generated and because you need to replicate the FPL API in C++ to be able to easilly convert the SWF into an iPhone app;
  • ActionScript is a dynamic language, and this dynamicity must be taken into account when generating binary code (or source code in my situation). Even if using LLVM probably helped with this, you will always need to generate additional dynamic checks that slow down a lot the execution;
  • The FPL doesn’t support (yet) threading API, nor the AIR version does. So, if they want to preserve the portability of a flash game so it can be run with AIR or on the iPhone without any change, they are limiting the developers on building just quite simple games;
  • The same can be said for all the other native APIs. AIR for instance has multitouch API, which are however at a lower level then the ones provided by the iPhone;
  • The other big issue is uk cheap essay writing rendering performance. When I was working on my project, I’ve tried many different approaches to figure out which one was the best to render decent vector graphics with a good framerate on the iPhone. Core Graphics is not an option, as long as it is as slow as hell. Using OpenGL to render the graphics increases a lot the performances, but adds a few limits to the rendering quality. The best approach I found was to mix caching and OpenGL rendering together, but that was not working fine with rapidly changing graphics. But I must say I didn’t have the same knowledge as the FPL developers on this topic and I didn’t have months to work on that too …
  • iPhone developers must take special care for memory and resource management; probably having a huge bootstrapping code and transition structures won’t help.

What I fear most actually is that they’ll be able sooner or later to solve all the issues and create a good product, but probably that product won’t be suitable for complex applications, that will be always developed directly using XCode.

That said, I think that probably a better approach would have been to figure out a way for Adobe to include the Flash Player on the iPhone. It’s already ready and I really can’t understand why they don’t release it ( http://www.cantieredirudino.com/expert-graduate-paper-writers-expert-graduate-paper-writers/ expert graduate paper writers expert graduate paper writers it must be Apple, and probably because having a Virtual Machine on the system will break the basis the App Store has been built over).
Having the FPL on the iPhone will still limit us, but it will open up a brighter future for AS developers who want to release apps that runs on the iPhone too (Did you ever heard about compile once, run everywhere?).

So let’s wait and see what happens. What I’ve seen so far on the app store are really simple games that don’t use so much resources, so I can’t really say yet if they did a great job or not …

A long journey through chunked transfer and file uploading

It has been a while since I wrote the last post … I know, I’ve still quite a lot of stuff left opened but http://www.designingdivas.com.au/money-cant-buy-health-essay/ money cant buy health essay sooner or later you’ll get it. phd without a dissertation Don’t worry 😉

During the last days I’ve been working on improving some server side API for a client I’m working for.

Actually they’re using a mix of http://blog.leadgraffiti.com/rush-university-admission-essay/ rush university admission essay AMF and HTTP based API but, as long as the AMF implementation is unfortunately a bit unstable, they want to move to a full HTTP based API … that sounded quite easy: take a bit of HTTP, dress it with POST and maybe XML (or whatever other ingredient you like most) and you’ll have a good base to start porting the API.

But I’ve ignored a small particular that turned out to be really painful to manage by using just HTTP: sending efficently to the server big chunks of binary data.

Those were the requirements I had to fulfill:

  1. I have potentially really big binary files to be sent quickly to the server;
  2. I have to track upload progress somehow;
  3. I must be able to trigger the upload without the user interaction;
  4. I should rely on HTTP only;

And here the solutions I’ve tried to implement, and the conclusions I’ve achieved (well, I didn’t try all the options because I already knew that a few of them were not suitable for my situation, but they might be useful to someone and so I’m reporting them anyway).

Continue reading

AsYacc – first alpha release

Before going further with discussing how to add runtime scripting support to a Flash applications, I’d like to share with you the source code of a porting of Yacc I did a while ago. I did some simple modification to make Yacc able to writing science essays generate ActionScript 3.0 source code instead of C. It works quite well and supports a lot standard Yacc features. There might be some issues – report them to me and I’ll try to fix them 🙂

You can easilly find documentation about Yacc searching Google (you can start here for example).

Usually Yacc is used in conjunction with a http://www.jadecoastjewelry.com/do-we-value-only-what-we-work-for-essay/ do we value only what we work for essay Scanner generator (like Lex/Flex), but I didn’t to any porting of commonly used Scanner generators yet.

Here you can download the sources. The http://www.pasqualesportiello.com/admission-college-essay-help-common/ admission college essay help common source code should be portable and compilable on all the most common platform, but I didn’t tested it on Windows yet. To compile the source code on Mac or Linux, cd to the source code directory and type use:

gcc *.c -o AsYacc

Once you have the compiled binary file, you can run the Parser generator using:

./AsYacc -Hpackage=it.sephiroth.test grammar.y

Where grammar.y is a text file that contains the grammar of a language defined using the proper syntax (see the docs online for all the detailed information you may need).

Here you can download a simple calculator example that uses the RegexLexer described previously to implement the Scanner. For the ones who might be interested, here is the grammar used:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* Infix notation calculator. */
%{
%}
%token NUM
%left '-' '+'
%left '*' '/'
%left NEG
%right '^' /* exponentiation */
%%
input:
exp         { trace( $1 ); }
;
exp:
NUM         { $$ = $1; }
| exp '+' exp     { $$ = $1 + $3; }
| exp '-' exp     { $$ = $1 - $3; }
| exp '*' exp     { $$ = $1 * $3; }
| exp '/' exp     { $$ = $1 / $3; }
| '-' exp %prec NEG  { $$ = -$2; }
| exp '^' exp     { $$ = Math.pow( $1, $3 ); }
| '(' exp ')'     { $$ = $2; }
;
%%

Scripting Flash apps: scanning the input file

Here we go. I know that probably I should have started this new topic talking about the grammar of the language we are going to implement, but as long as I see grammar strictly related to parsing, I’ve preferred to talk about http://profesyonelgayrimenkul.com/phd-thesis-on-microcontroller/ phd thesis on microcontroller scanning first.

We will go back to the grammar the next time, when talking about how to parse an input file.

I wrote about scanning (or criminal justice research proposal example lexing if you prefer) a while ago, when blogging about expression evalution in ActionScript. Scanning an input file is quite always the same (although some languages might require unusual features), and what I wrote about expressions works also for a general language.

The goal of the scanning process is to group some characters together, skipping the ones that have no meaning for the language like spaces. Each group of characters is usually called http://www.srisiddheswariseva.org/who-will-do-my-homework/ Who Will Do My Homework token. So a http://www.holidayhometimes.com/help-with-writing-a-essay/ Help With Writing A Essay Scanner converts a textual input into a stream of tokens, each one rappresenting a possible valid word for our language. While scanning you don’t take care about the meaning of what you are grouping or about the fact that a sequence of tokens is meaningful. This is a task for the http://danandcharlotte.info/how-to-buy-papers-for-college/ How To Buy Papers For College Parser as we will see.

When talking about expressions, I showed a manual implementation for a Lexer. Now I want to take a different approach and show you a possible implementation for a simple dynamic scanner. This scanner will be based on regular expressions: each regular expression will rappresent a given token, and we will be able to assign callbacks to the scanner that will be executed each time a given token is extracted from the input.
Writing a general and reusable scanner is usually a good practice. A common approach is to use some http://blog.ibadanbusinessschool.com/how-to-write-a-good-essay-for-college-application/ How To Write A Good Essay For College Application scanner generators, that are usually regular expression based too but are able to generate the code for a scanner at compile time. Our approach is different (and generates slower scanners) because regular expressions are evaluated at runtime; but it is fine for a test project.

You can download the source code for the regular expression based lexer (RegexLexer) here, as long as a simple usage example. Let’s see this example together so we can briefly discuss it (PBLexer.as):

Continue reading

Scripting Flash apps: design the language

Finally I had a bit of time to go back to the discussion I started about a month ago: scripting your flash applications. I spent a bit of time thinking which is the best approach to start discussing this kind of topic; it is not as easy as it seems because the risk is to fall into a too complex discussion that a lot of people won’t benefit from.

So I decided to start with a simple example that is somehow related to what I’m doing in these months; more examples will come and I’ll analyze different aspects of scripting trying always to keep the discussion as simple as possible even if this may bring me to do avoid some hard to discuss approaches or optimizations.

Our first scripting language will be an extremely simple language that will be used to manipulate images (like Pixel Bender does). Obviously the goal is not to write something that can be compared with Pixel Bender, but at least we would like to provide an implementation that will lead to scripts as fast as native code (at least we hope so :P).

The first step is to design the language, and to do that we need to do the step zero that is to define the goals we want to achive with the first implementation:

  • The language must be extremely simple to design and implement (it is a didactic stuff indeed!);
  • The language must be as simple as possible to learn and use: we won’t be an alternative to Pixel Bender (because we can’t … yet ;P)
  • The language must be quick to compile and execute.
  • A script must accept some parmeters to control its behaviour.
  • We must support comments!

Now that we decided which are the goals, let’s start definign some limitation or features we must include to quickly reach a solution:

  • The first implementation of the language will support a sigle data type: Numbers. We will move further adding more data types later – I don’t want to focus on type checking yet.
  • We will add support for basic expression operators, basic control flow. No support for functions yet.
  • The language will provide some useful operators or builtin functions to manage common operations like packing/unpacking color components and peform some mathematical operations.
  • Arguments to a script will be only Numbers at first.
  • A script will be defined as a simple sequence of arguments followed by a function definition. This function will be applied sequentially to every pixel of one or more source images.
  • We will provide to implementations for the language: a simple (and slow) interpreter at first, then we will generate native SWF code to speedup the performances.

Even if briefly, it is quite important to define the goals of our language and then the features, because a lack of design (even if extremely simple and poor as the current one :P) may lead to unexpected issues during implementation.

Now that we defined those basic pointers, let’s see how the language will look like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Simple crossfade filter
// The crossfade intensity
argument intensity;
/**
* A quick explanation of the used builtins:
*  - in( id, x, y ): gets the ARGB color at x and y of the image identified by id (there can be more than one image as input);
*  - out( id, x, y, color ): sets the ARGB color at x and y for the output image identified by id;
*  - argb( a, r, b, b ): build an ARGB color from its components (clamping and rounding the values as required);
*/
evaluatePixel( x, y )
{
// this kind of assignment is similar to the python unpack assignment
// but extracts the 4 components (ARGB) from a color.
a1, r1, g1, b1 = in( 0, x, y );
a2, r2, g2, b2 = in( 1, x, y );
out( 0, x, y, argb(
( 1 - intensity ) * a1 + intensity * a2,
( 1 - intensity ) * r1 + intensity * r2,
( 1 - intensity ) * g1 + intensity * g2,
( 1 - intensity ) * b1 + intensity * b2 ));
}

As a side not, I must say that the language may change during implementation because of unexpected limitations we will find during development.

Next week we will move forward start implementing the language. Stay tuned!

Scripting your Flash applications …

As someone of you may know, I really like studying programming languages and sometimes implement for fun (or for work) simple scripting languages that help me out during development.

The fight between scripting and programming languages will probably never end. Well, it is not really a fight but more an infinite race where the first position is exchanged continuosly between the two participants.
We need flexibility first, and so we add to our complex applications a way to support scripting to be able to easilly perform changes without the need to run the long time taking compilation process a low level language might take; then, the more the scripts became complex, the more we need an increase in performances, and so we rapidly move to compiled plugin egines; plugins offer a bit of flexibility and usually a good speed. Then we grant other users the permission to write plugins and so we need a sandbox to run the plugins in and to be sure every single line of code that is executed doesn’t harm our application. And so we revert back to scripting … and so on.
The race will never end but the technologies will continue to increase in speed and sometimes in complexity.

All the introduction is to say that its not the point to choose if scripting is useful or not for Flash applications, but to say that someone might need it for reasons we cannot think about right now, and someone else might not need it because they are fine with recompiling everything from scratch at each single small change.

I don’t think there are some many Flash applications that support scripting. I built myself a few of them for my company but they are for a particular purpose and probably the same motivations that made me decide to implement a scripting language are hard to find for other kind of applications.

As far as I know, the most of the applications that need to be flexible use a plugin system (more or less complicated – as Aviary for instance and Hobnox) and are fine with it because – we must say that – ActionScript is itself a scripting language and a SWF file is nothing more than a bunch of instructions (more or less) generated by compiled ActionScript.

But sometimes security comes into account, and it is hard (even if possible) to limit the funcionalities used by a plugin if this plugin is created by a 3rd party developer.

And so it comes into account scripting. With scripting we have full control over what a developer can do an how he can do that. We can limit it, provide builtin functionalities … But everything costs something, and building a fast/flexible/powerful/useful scripting languages is not that easy as it might seem.

This is why I decided to spend a bit of time in explaining the basics to implement a scripting language in actionscript to be able to script our applications. I’ll walk through all the passes – from lexing to bytecode generation and maybe a quick look into Virtual Machines – with the aim to provide someone (maybe in the far future) a bunch of documents to use as reference to build their own scripting language.

I’ll try to give an in depth look, but as far as the argument is quite complicated and full of facets, you may not find here the right solution for you. Nor the fastest or the most flexible. But it is better then nothing so if you are interested in that keep reading the blog 🙂

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 😉

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