Connect to a remote Flash Media Server Shared Object from a client Flash.
Hardly mentioned anywhere, but, suppose you have a Shared Object on a running application in Flash Media Server
(let’s call it: theApp), and you want to access it from the client:
THIS IS NOT ENOUGH:
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, function(e:NetStatusEvent) {
if (e.info.code == "NetConnection.Connect.Success") {
getSO:SharedObject = SharedObject.getRemote ("SOName", nc.uri, true);
}
}
nc.connect ("rtmp://yourserver/theApp");
It won’t get an updated version of the
SOName SharedObject, apparently.
You have to call the “
connect” method
on the SO, and then wait for the
SyncEvent.SYNC event:
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, function(e:NetStatusEvent) {
if (e.info.code == "NetConnection.Connect.Success" {
getSO:SharedObject = SharedObject.getRemote ("SOName", nc.uri, true);
getSO.addEventListener (SyncEvent.SYNC, soSync);
getSO.connect (nc);
}
}
nc.connect ("rtmp://yourserver/theApp");
function soSync(e:SyncEvent) {
trace ("SYNC!");
trace (e.currentTarget.data.yourproperty);
//Use the properties of the SO
}
And then the properties of the
SO will be available in the data property.
Cross-browser Flash Player version detection in Javascript
This post’s intention is to try to describe and achieve a light-weighted,
cross-platform, cross-browser Javascript function that will detect the version of the Flash Player plugin installed on a browser, and return it, as a string.
The code is based on the Flash-Player version detection techniques used in the SWFObject source file.
The function return false if it is unable to find and detect the flash player’s version.
The function:
// Function to detect installed flash-player's version and return it as a
// string in the format of 'MajorVersion.MinorVersion'
function getFlashPlayerVersion() {
var nav = navigator;
if (!nav) {return false;}
//If not navigator.plugins - assume IE
if (nav.plugins.length == 0 || typeof nav.plugins == "undefined") {
var ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
if (!ax) {return false;}
var flversion = ax.GetVariable("$Version");
var retver = flversion.substring (flversion.indexOf(' ')+1,
flversion.indexOf(',',flversion.indexOf(',')+1));
//The Version variable in IE appears with a comma and not a dot - replace it:
return retver.replace (',','.');
}
//Has navigator.plugins - assume non-IE:
else {
if (!nav.plugins["Shockwave Flash"]) {return false;}
var flashinfo = nav.plugins["Shockwave Flash"];
if (flashinfo.version) {return flashinfo.version;}
if (flashinfo.description) {
//Parse just the version part from the description
var fldesc = flashinfo.description;
var flver = fldesc.substring (fldesc.indexOf('Flash')+6,
fldesc.indexOf(' ',fldesc.indexOf('Flash')+7));
return flver;
}
else {return false;}
}
}
The inner workings:
Detection for IE rely on the GetVariable(“$Version”) function of the ActiveXObject.
Detection for non-IE browsers rely on the navigator.plugins[“Shockwave Flash”] object.
Some browsers (e.g. Mozilla Firefox) has a version property for this object, other browsers has the version number inside the description property of the object.
Testing Table:
| Platform | Browser version | Flash version | Test result |
|---|
| PC, Windows | Firefox 3.6 | Flash 8.0 | Works |
| | Flash 9.0 | Works |
| | Flash 10.0 | Works |
| | Flash 11.0 | Works |
| Firefox 7 | Flash 11.0 | Works |
| IE 7 | Flash 10.3 | Works |
| IE 9 | Flash 11.0 | Works |
| Chrome 14.0 | Flash 11.0 | Works |
| Safari 5.1 | Flash 11.0 | Works |
| Opera 11.51 | Flash 11.0 | Works |
| | | |
| MAC, OS X 10.5.8 | Safari 5.0.2 | Flash 10.0 | Works |
| Firefox 3.6 | Flash 10.0 | Works |
| Chrome: 15.0 | Flash 11.0 | Works |