views:

45

answers:

1

I have a swf that opens up inside a colorbox window. When the video finishes playing, I make an externalinterface call to a javascript function to close the colorbox.

I'm trying to execute the following AS3 code:

ExternalInterface.call('parent.$.fn.colorbox.close()')

I can't seem to get this to work. The colorbox won't close.

I also tried this to see if I was just making the wrong function call, but this didn't work either: ExternalInterface.call('alert("hello world")')

However, if I browse to the url of the swf file, so that it doesn't open inside the colorbox, the alert() call works just fine.

+1  A: 

Try this:

ExternalInterface.call('parent.$.fn.colorbox.close');

And this:

ExternalInterface.call('alert','hello world');

Alternatively, you could call eval and pass JS code as a String (you don't need this here, but it's handy in some cases).

ExternalInterface.call('eval','parent.$.fn.colorbox.close()')
Juan Pablo Califano
This didn't work.
Adam
@user362871. Maybe your embed code is denying your swf access to JS... Can you paste your embed code?
Juan Pablo Califano
I don't have it embedded. I am using colorbox to load the swf directly. Will try embedding it in an html page and calling that with colorbox.
Adam
I got it to work by calling an html file that contained the swf. When I placed a javascript function in the html file that called parent.$.fn.colorbox.close(), and called it from the ExternalInterface command then it worked.
Adam
@user362871. Glad you sorted it out. Must be some kind of security sandbox restriction.
Juan Pablo Califano