In newer versions of Flash there's the
ExternalInterface class to handle communications with the movies container.
It has been alot easier to work with than
FSCommand ever was & I've not had any issues with it working on the latest versions of browsers.
There's two very usefull methods of the
ExternalInterface class.
1)
call
2)
addCallback
ExternalInterface.call makes it easy to call a
javascript method from
flash.
ExternalInterface.addCallback makes it easy to call a
flash method from
javascript.
I use both of the methods
here to do a couple of things.
One of them being sync the current theme color between the HTML & the SWF header.
The other being accessing the browsers address bar to make videos bookmarkable.
You can take a look at
the javascript to see how that part works.
The part you don't see, that works in the header animation is this.
import flash.external.ExternalInterface;
// Declare
var themeColor:Number = 0x00ff00;
var _ = ExternalInterface.call("readCookie", "themecolor");
if(_ != null){
if(_ == "color-blue"){themeColor = 0x0000ff;}
else if(_ == "color-red"){themeColor = 0xff0000;}
else if(_ == "color-pink"){themeColor = 0xff00ff;}
else if(_ == "color-yellow"){themeColor = 0xffff00;}
}
// ...
ExternalInterface.addCallback("swfSetTheme", this, scan);
- import flash.external.ExternalInterface;
- // Declare
- var themeColor:Number = 0x00ff00;
- var _ = ExternalInterface.call("readCookie", "themecolor");
- if(_ != null){
- if(_ == "color-blue"){themeColor = 0x0000ff;}
- else if(_ == "color-red"){themeColor = 0xff0000;}
- else if(_ == "color-pink"){themeColor = 0xff00ff;}
- else if(_ == "color-yellow"){themeColor = 0xffff00;}
- }
- // ...
- ExternalInterface.addCallback("swfSetTheme", this, scan);
The code for the video bookmarking is similar.
Strong with this one, the sudo is.