cacheAsBitmap hell

Last week I spent a whole day trying to solve an issue in Phoenix due to a strange problem which comes up suddenly after some code changes.
The problem was that now using the transformation tool the bounds of the selected bitmap were not detected correctly and the tool itself didn’t work.
So I spent a lot of time in checking out all the recent code changes ( and they were a lot! ) to find out the possible cause…
Anyway, I was lucky to figure out the problem by accident and the problem was cacheAsBitmap!

The problem with the tool is because in order to find the correct bounds of any element on the stage it use the .concatenatedMatrix property of the element itself ( which represents the combined transformation matrixes of the display object and all of its parent objects, back to the root level ).
BUT if any of its parent display object ( not the root itself ) has the cacheAsBitmap property set to true then the concatenatedMatrix returns a wrong value!

I put a real simple flash example of what I mean. Just click on any of the 2 colored objects to activate the transform tool, then click on the “cache” button and click again on those objects to see the difference.

[kml_flashembed publishmethod=”static” fversion=”10.0.22″ movie=”http://blog.sephiroth.it/wp-content/uploads/2008/03/cacheasbitmap_hell.swf” width=”450″ height=”450″ targetclass=”flashmovie” bgColor=”#ffffcc”]

Get Adobe Flash player

[/kml_flashembed]

P.S. I’ve reported the bug in the flash player bugbase, if anyone is interested in watch or vote for it.

iPhone & Ubuntu notes…

No Flash stuff this time 🙂
During my last trip to New York city I finally decided to buy an iPhone for me too (I think I have everything from Apple right now.. except a mac 🙂 ).
The most annoying thing for a linux user like me is obviously the fact that the iPhone syncronization should pass from iTunes, which is not available for linux…
Ok, there are some ways indeed to copy music like this: http://help.ubuntu.com/community/PortableDevices/iPhone, but as you can see is not so smart.

Sync your address book isn’t easy too. The AddressBook sqlite can be easily browse using an SQLite browser such as SQLite Database Browser http://sqlitebrowser.sourceforge.net/, just get the AddressBook.sqlitedb (it’s into  /private/var/mobile/Library/AddressBook/)  from the iphone via sftp (just remember to install BSD Subsystem and OpenSSH) and call a simple query like this:
SELECT t1.First, t1.Last, t2.value from ABPerson as t1, ABMultiValue as t2 WHERE t2.record_id = t1.ROWID
For a full AddressBook sync you can read more here: http://www.estamos.de/blog/…the-making-of/

Another tip I just discovered is how to upload into the iPhone my own Ringtones.
First convert the mp3 file into an M4R file using this command line script:
mplayer -ao pcm input_file.mp3 -ao pcm:file="~temp.wav"
faac ~temp.wav -o output_file.m4r -w
rm ~temp.wav

then using sftp put the output_file.m4r into /Library/Ringtones directory. A sample workflow can be this one:
~/iphone/Ringtones$ mplayer -ao pcm The_Spell.mp3 -ao pcm:file="~temp.wav"
MPlayer 1.0rc2-4.2.3 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 CPU T7600 @ 2.33GHz (Family: 6, Model: 15, Stepping: 6)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing The_Spell.mp3.
Audio file file format detected.
Clip info:
Title: The Spell
Artist: Lunatica
Album: Fables & Dreams
Year: 2004
Comment: 00001A75 000016D0 00004374
Track: 6
Genre: Other
==========================================================================
Forced audio codec: mad
Opening audio decoder: [libmad] libmad mpeg audio decoder
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [mad] afm: libmad (libMAD MPEG layer 1-2-3)
==========================================================================
[AO PCM] File: ~temp.wav (WAVE)
PCM: Samplerate: 44100Hz Channels: Stereo Format s16le
[AO PCM] Info: Faster dumping is achieved with -vc null -vo null -ao pcm:fast
[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).
AO: [pcm] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
Cannot sync MAD frame 538.0 (08:58.0) 0.8%
Cannot sync MAD frame
Cannot sync MAD frame
Cannot sync MAD frame 538.0 (08:58.0) 0.8%
A: 288.3 (04:48.2) of 538.0 (08:58.0) 0.8%
Exiting... (End of file)
alessandro@alessandro-u-laptop:~/iphone/Ringtones$ faac ~temp.wav -o The_Spell.m4r
Freeware Advanced Audio Coder
FAAC 1.26.1 (Jan 22 2008) UNSTABLE
Quantization quality: 100
Bandwidth: 16000 Hz
Object type: Low Complexity(MPEG-2) + M/S
Container format: Transport Stream (ADTS)
Encoding ~temp.wav to The_Spell.m4r
frame | bitrate | elapsed/estim | play/CPU | ETA
12388/12388 (100%)| 137.8 | 12.5/12.5 | 22.95x | 0.0
alessandro@alessandro-u-laptop:~/iphone/Ringtones$ sftp root@192.168.1.203
Connecting to 192.168.1.203...
root@192.168.1.203's password:
sftp> cd /Library/Ringtones
sftp> put The_Spell.m4r