Capabilities API - Know more about your users
Created By Abdul - 0 Comments Published by Monday, October 22, 2007 at 9:03 AM .Often, we develop applications which need to know about client-machine's capabilities in order to provide optimal experience. For example, we might need to know following in different scenarios:-
- What is client's screen-resolution?
- What is client's Operating-System (OS)?
- What is Adobe Flash runtime (Flash Player or AIR) version?
- What is system-language (English or German etc) of the machine?
- What is player type (Standalone or browser-plugin)?
- Does client have audio/video support?
- Does client support accessibility aids (screen-readers etc)?
- Does client support SSL/TLS transport?
- Is client allowed to use Microphone/Webcam (in restricted/administrated environments - corporates/institutes etc)?
Adobe Flash runtimes (Flash Player and AIR) provide Capabilities API to know all these (above and more) about client-machine. You can use various static properties to determine various capabilities of client machine.
For example:-
//To know horizontal-screen-resolution
var screenResolutionX:Number = Capabilities.screenResolutionX;
//To know vertical screen-resolution
var screenResolutionY:Number = Capabilities.screenResolutionY;
//To know operating-system - returns "Window", "Linux" or "MacOS".
//Wherecould be different versions (2000 or XP etc) of MS-Windows.
var operatingSystem:String = Capabilities.os;
Check out the Capabilities API to learn all about it.
Labels: api, capabilities
ActionScript developers has been using escape()/unescape() functions to encode/decode Uniform Resource Identifiers (URI). Technically, escape() works differently.
Adobe Flash Player 9 introduced some API (global or top-level) functions encodeURI, decodeURI, encodeURIComponent and decodeURIComponent to work with URI encoding.
It is recommended to use these new functions for URI encoding/decoding.
I thought of writing the difference between escape() and new API functions but following blog posts would explain better than me.
Note: Above links are in context of JavaScript and Browser, I am expecting (assuming) behavior of ActionScript functions in Flash Player should not be different, since all of these follow same standard(s).
flash.net.SharedObject
Created By Ted Patrick - 1 Comments Published by Friday, October 12, 2007 at 2:46 AM ."Cookies are to the Browser as SharedObject is to Flash Player/AIR."
SharedObject allows you to persist data in object form on the client side in Flash Player or AIR. It is an incredibly simple class with some profound implications when used properly. Since Flash Player 6 you have been able to persist data using SharedObject to disk on the end users machine, you cannot write arbitrary files but you can store up to 100K of data in object form which is pretty cool.
API DOCUMENTATION
EXAMPLE:
var so:SharedObject = SharedObject.getLocal("scores");
so.data.highScore = new Number(892343);
so.data.lowScore = new Number(5934);
so.data.recentScore = new Number(382234);
so.data.gamerName = new String("adobeted");
so.flush();
MORE:
You create or open a SharedObject using the getLocal method with a unique path or domain. SharedObjects can only be read on domains where they are set so they have a handy security implication that is being used at Bank of America, Yahoo and other sites for extra security on web transactions. The security model for SharedObject is located here
Once you have a SharedObject instance you simply write data into the data object. When the Flash Player/AIR instance quits all SharedObject data is flushed to disk but you can force writing to disk using the flush() method.
SharedObject data can also be synchronized using the RTMP protocol and are the primary data exchange technique for use with Flash Communication Server.
USES:
- Tracking users with a GUID
- Persisting username for login fields
- Storing UI state
- Storing history for local user
- Synchronizing data between clients (FMS via RTMP)
- Store any data between requests
Hidden APIS
I am firing up the "Hidden API" Blog. If you are interested in contributing to Hidden APIS, please contact me at ted@adobe.com. I am looking for various opinions on the different APIS as my perspective is far from the only one that matters. I think we can all learn a ton about the lower level features of Flash Player/AIR/Flex/Flash here sharing how the various APIS are used. Hidden APIS should be a fun long term project and now that I have time, lets get this party started.
Cheers,
Ted :)