16 October 2008

Why you shouldn't use setInterval

Some days ago, I was finishing a title screen for my coming game.
It's pretty simple : wait 3 sec then jump to next frame.

To do that I mainly use setInterval on web based Flash :
idInterval = setInterval( myFunc, 3000)
and, on myFunc :
gotoAndPlay(nextone)
clearInterval(idInterval)
idInterval = null
delete idInterval

Well...as you should know, it's really important to clean everything not wanted when you finished a job. Since AS's object haven't a destructor, I do it on onUnload.
It works! ... but not when you use an interval.

Yes, I don't know why (a internal listener not cleaned ?) but onUnload isn't called when you have an interval EVEN when you nulled and deleted it (see below).

So, I replace my setInterval with
onLoad :
initTimer = getTimer( )
onEnterFrame :
if ( (getTimer()- initTimer) >= 3000 ) gotoAndPlay(nextone)

As always, if you have some hints, I'm here!

03 October 2008

Flash Lite will have access to S60 OS !

...Well soon ;)

From Biskero, Nokia released a new document on S60 5th Ed with some API for Flash Lite.
I quickly downloaded the SDK but, unfortunatly, the S60FlashLiteExamples folder is empty.

Wait and see...
With NFL and this, I really start to think SE's Capuchin made Nokia move !

NFL and cache issue

With my new phone and Mocket's SWF2NFL, I tested NFL deployment.

2 ways to do it under Apache :

  1. add 'application/vnd.nokia.flashlite-archive[insert_tab]nfl' on the file 'mime.types' (see TypesConfig in your 'httpd.conf' to know where it is) then restart apache with apachectl restart

  2. create/update a '.htaccess' file on the folder when you uploaded the NFL and add 'AddType application/vnd.nokia.flashlite-archive nfl' inside (works only if .htaccess are authorized via 'AllowOverride All' in the 'httpd.conf')



I uploaded 'test.nfl' on the correct folder of my server and downloaded it to my mobile throught Opera Mini.
After some tests, I found a bug and so updated 'test.nfl'.
I then tried to download the new version to my mobile but I was unable to overwrite the previous one, I so gave it a new name 'test1'.

Problem step 1 :
I don't have 'test' and 'test1' but 2 'test' files.
I so thought it was because I used the same version number.
So I made a new 'test.nfl' with a new icon and a new version number.

Problem step 2:
Download, call it 'test2' and....3 'test' files on the folder with the same icon !

Problem step 3:
Ok...I deleted these 3 files, cleared cache from Opera and restarted download to another folder...Still the old one!
I'm lost : old one was 12ko, new one is 23ko...Opera tell me it is about to download a 23ko file and...I have the old 12ko on my mobile ?!

Answer :
After some googling, I found a link to clear 'nokia cache'
I followed the instructions, restart the download and....finally got my 23ko file !

Conclusion:
I must say I'm a bit disappointed...
1/ an user can't update (overwrite) a file
2/ if cache isn't cleared, user still download the old one

Note, I don't know the life time of the cache but it can be an issue.
I wasn't aware of download caching, it's my first experience : always delete a file and clear cache before downloading the new version.
It still strange for me to have to clear Opera cache AND Nokia cache to download the right file.

I also know why the files kept 'test' as name, it's the FL-Name which is used, not the filename...but I must say it's strange to have 3 differents files with the same name !
Why not use this FL-name and FL-version to update the file, not create a new one ? or use a FL-UID ?

Well, first step to easier deployment....for easier ONE SHOT deployment. Forget about update.

If your phone doesn't work the same way, tell me !

My new phone

Yesterday I finally received my 5310 XpressMusic (the E71 was too expensive for me, hélas).




I choose this one because it's a S40 5ed FP1 of course.


I took a 500mb limit plan so I'll finally be able to test XML feature from Flash Lite on the web.


I like this phone, especially its weight!
But I must say its keyboard is very different from my N70's one : I first thought it was a toy !
We'll see how long I will use it !

01 October 2008

Garbage collector

I was trying to optimizing my MobileCairngorm (more info soon) when I googled to a very useful article on Adobe's Mobile Developer Center : Memory management and optimizations in Flash Lite
So bad I missed this one (from June 2007!)
Of course, others parts of the article are interesting but I was fighting with memory so...

Note some parts of this article can also be found in Flash Lite Help (link to LiveDoc)

The two things I noticed are
  1. GCollector runs every 60secondes...I was unable to see it works on Device Central's memory monitor.
  2. You can delete classes for unloaded SWF.

the point 2 is very interesting so I made some tests

  • delete class B which inherits from class A will only delete class B
  • it seems object of deleted class B will still have class A properties, events, functions (read will become something like an object of class A)
  • article talk about loaded SWF, so I tried with movieclips inside my main swf, to see if it works the same : if I delete a class on movieclip 1 (on unload) and then attach movieClip 2, this new movieclip doesn't reload the class. It seems a deleted class is lost for ever...in the SWF.