views:

110

answers:

2

I want to have my overlay adjust in size depending on how much content is being shown in the flash movie. Also, I want it to resize in real time when the user adjusts the content.

Is it possible?

+3  A: 

Sure, Flash can call methods in Javascript using ExternalInterface. The syntax is pretty simple, say in Javasacript you have:

function methodInJS(name) {
   alert("Hello to " + name);
   return 17;
}

Then in Actionscript you would call:

var myName:String = "David";
var result:Number = ExternalInterface.call("methodInJS", myName);
trace("Result from JS call is: "+result);
davr
+1  A: 

Yes, use ExternalInterface

In you HTML set up your shadow box like this:

<link rel="stylesheet" type="text/css" href="shadowbox.css">
<script type="text/javascript" src="shadowbox.js"></script>

<script type="text/javascript">
Shadowbox.init({
    skipSetup: true
});

function openShadowbox(content, type){
    Shadowbox.open({
        content:    content,
        player:     type,
        title:      "Welcome",
        height:     350,
        width:      350
    });
};
</script>

Then in your ActionScript:

if(ExternalInterface.avilable){
 try{
  ExternalInterface.call("openShadowbox", "<h1>Welcome to my website!</h1>", "html");
 }catch(error:Error){
  trace(error);
 }
}
jwerre
thanks. How would I change the dimensions of the shadowbox and have it center etc....
Adam