Skip to main content
Inspiring
December 5, 2006
Question

Triggering javascript with actionscript

  • December 5, 2006
  • 2 replies
  • 300 views
I have created a movie clip that, upon completion, I want to shake the browser window using the following javascript that I've embedded in my HTML ...

function shake_xy(n) {
if (self.moveBy) {
for (i = 10; i > 0; i--) {
for (j = n; j > 0; j--) {
self.moveBy(0,i);
self.moveBy(i,0);
self.moveBy(0,-i);
self.moveBy(-i,0);
}
}
}
}
function shake_x(n) {
if (self.moveBy) {
for (i = 10; i > 0; i--) {
for (j = n; j > 0; j--) {
self.moveBy(i,0);
self.moveBy(-i,0);
}
}
}
}
function shake_y(n) {
if (self.moveBy) {
for (i = 10; i > 0; i--) {
for (j = n; j > 0; j--) {
self.moveBy(0,i);
self.moveBy(0,-i);
}
}
}
}
//-->


What would I write in my actionscript to make this happen? I've tried getURL("javascript:shake_x(10)"), but that didn't work.

Thanks in advance -
This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
December 5, 2006
you're welcome. you had a typo in your first message that you may have had in your flash file.
kglad
Community Expert
Community Expert
December 5, 2006
try: getURL("javascript:shake_xy(10)"), or better yet, use the externalinterface() class (if you have flash 8).
Inspiring
December 5, 2006
Thank you for the suggestions. I tried the getURL method, and that didn't work. I've never used the externalInterface class before. I have Flash v8. How would I reference the javascript function "shake_xy(10)" using the externalInterface class assuming that I want the browser window to shake upon completion of a movie clip?

kglad
Community Expert
Community Expert
December 5, 2006
if you tried getURL and failed, copy and paste the getURL code from your flash.

to use the externalinterface class check the flash help documents: