iPhone String Avoider prototype with Adobe Flash Professional CS5.5

I am considering to port Stringy on the iPhone and after seeing the Corona SDK example I tried to convert the AS3 String Avoider prototype for the iPhone, using the guidelines in the post Creation of an iPhone App with Flash and without a Mac.

So, I wrote this code:

Which is basically the same as the original prototype, just dragging the string when the finger (mouse) is down and showing a circle where to tap (click) to start dragging again if the player leaves the finger (releases mouse button).

Play with the result:

Drag the white circle to move the string.

I also optimized a bit the code defining the class as final since it’s not meant for being extended and its methods aren’t meant for being overridden. final classes should execute faster than other classes, and since I am looking for the best performance improvement, I used this trick.

Using static in some variable declarations also should increase the speed. static specifies that a variable (or a constant) belongs to the class rather than to the instances of the class.

Finally, cacheAsBitmap method allows me to render the Display Objects as bitmaps rather than vectors. You may say “just use a PNG image then”, and you’re right, but I wanted to keep the code as much similar to the original as I can.

This is the final example of the app working on my Iphone4:

It works quite well although I am considering using a sequence of dots rather than a thin line, I will keep you updated.

  • Good work! Do you know if there is some limitations to IPhone apps published from Flash environment? I did two of them, but they did perform badly on older IPhone models, and never published them to the store. Did you successfully published some IPhone app on the App store? Thank you

  • Chris

    Wow this looks really smooth for flash on iPhone! I had always performance issues..
    Very nice as usual. Keep up the good work and Merry Xmas!

  • gdev

    whats the code to detect if a star is inside d circle loop?

  • Ben

    looks good!!

    could squeeze out some extra speed there by not creating new points in the update function, just reuse from a cache. sure its only 300 odd points but creation is expensive as I am sure you are already aware :)

  • greg

    About PNG and cacheAsBitmap,

    what if you use sprite class that contains PNG?
    even tough you have select cacheAsBitmap true cause in other case
    is taken as vector? right?

    You may say “just use a PNG image then”, and you’re right, but I wanted to keep the code as much similar to the original as I can.

  • Emanuele Feronato

    @codesurgeon: not yet, but I’m working on it

    @gdev: I’ll explain it during next posts

    @greg: interesting question, I think so but I’ll make some tests

  • p

    Is it possible to add advertising mobile flash apps?
    Or how to monetize?

  • p

    …add advertises to a mobile flash apps made with flash cs5,5?

  • Vishwas

    How can i run it on my iphone. Have you uploaded it on appstore, so that i may try running it ?

    Thank you