Skip to content

Instantly share code, notes, and snippets.

@Niek
Created February 22, 2011 12:29
Show Gist options
  • Save Niek/838600 to your computer and use it in GitHub Desktop.
Save Niek/838600 to your computer and use it in GitHub Desktop.
Actionscript (3.0) code to match colors of a banner with the site it's showing on
// Allow access from Javascript
flash.system.Security.allowDomain("*");
// To be called from Javascript when colors are returned
function setcolors(colors) {
var bgcolor = new ColorTransform;
var fgcolor = new ColorTransform;
bgcolor.color = parseInt(colors[0].substr(1), 16);
fgcolor.color = parseInt(colors[1].substr(1), 16);
// Change the colors of objects in your banner to either fgcolor or bgcolor
BannerLabel.BannerTextField.transform.colorTransform = fgcolor;
BackgroundClip.transform.colorTransform = bgcolor;
}
// Call the Javascript function getbannercolors() in order to request colors
if (ExternalInterface.available) {
ExternalInterface.addCallback('setbannercolors', setcolors);
ExternalInterface.call('getbannercolors');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment