Building Facebook Applications with Flash CS3
Open social networking website with 70 million users worldwide Developers’ API readily available for many platforms Free (like FUG)
Very useful resources Flash CS3 /Flex/… Facebook AS3 API from Google Code AS3CoreLib from Google Code PHP (http://php.net) Useful Resources UploadPostHelper http://marstonstudio.com/?p=36 PHP Proxy http://www.abdulqabiz.com/blog/archives/general/php_prox y_script_for.php
Flash/Flex App SWF
FB AS3 API
FB API Service Endpoint
Start desktop session using AS3 API
Authenticate user against FB and get session key
Validate the session using the session key
Request Extra Permissions (Photo Uploads)
FB API ready
Session key ready
Make an effort to request for the lowest level of authentication required for application to function Always provide a log out option for the user Be responsible with the data you have access to
No honey (crossdomain.xml) on Facebook image farms crossdomain.xml only available on Facebook service endpoint (http://api.facebook.com)
Iframe in Facebook FBML app? Cross‐frame scripting not allowed. AllowScriptAccess=“never” crossdomain.xml still on api.facebook.com!
PHP/ASP.NET/JSP/… Proxy
3
2
1 Application gets photo URL through FB API call.
Application contacts proxy with image URL to fetch
Image is relayed back to Application from proxy
Maximum concurrent http connection is 2 for most web servers Slow and a waste of bandwidth Possible access restrictions when setting up crossdomain.xml on proxy server
Loader bug in Flash Player Memory not freed up (Can be solved using LC hack) Connections not closed (Can’t be solved?) Memory go sky‐high (just like oil and rice) Immediate connection requests get delayed
Split the job Implement a download queue to restrict concurrent downloads through proxy Worst case: Incur a single download delay For large downloads: restrict concurrent downloads to max concurrent downloads of server‐1
Photo 1
Photo 2
Photo 3
Photo 4
Photo 5
Photo 6
Photo 1
Photo 2
Photo 3
Photo 4
Photo 5
Photo 6
Photo 1
Photo 3
Photo 2
Photo 4
Photo 5
Photo 6
Photo 1
Photo 3
Photo 2
Photo 4
Photo 5
Photo 6
Photo 1
Photo 3
Photo 2
Photo 4
Photo 5
Photo 6
Photo 1
Photo 3
Photo 2
Photo 4
Photo A
Photo 5
Photo B
Photo 6
Garbage Collection For a well written explanation of how the Garbage Collector works, refer to Grant Skinner’s resource management article http://www.gskinner.com/blog/archives/2006/0 6/as3_resource_ma.html
Garbage Collection Involuntary “Encouraging”/Forcing GC to take place Memory management especially important for resource intensive applications
Issues No easy and definite way to clear garbage in AS3 delete keyword can only be used to delete dynamic properties System.gc() only for debug and Adobe AIR
LocalConnection Hack Attempts to “encourage” the garbage collector to work Remove all references before using the hack (eventListeners, variables referencing loader etc) Does not consistently work when used alone!
The “Dummy” Load in a dummy image file (a blank gif file) Immediately unload the dummy Couple with delayed call to LC hack Consistent free up of memory
Short Comings Incur a minimum memory cost of the blank image being loaded Tradeoff for memory hogged by memory intensive resources (e.g. 5mB image for a 43kB blank gif image)
Example
Turbanizer Demo
Email:
[email protected]