Skip to main content
March 29, 2010
Question

How do you execute external javascript on last frame?

  • March 29, 2010
  • 1 reply
  • 1387 views

I have searched and read and searched some more, but have had no luck . . . could be because I'm new to Flash and Action Script and don't know enough to know what terms to search for.

I'm authoring in Flash CS4 using Motion Tweens.

Here is the situation.  I have a JavaScript that closes the DIV containing my flash object.  It currently closes after 15 seconds.  That is supposed to be how long the Flash movie lasts.  however, slower machines run the movie longer.  this means the flash object closes too quickly and they don't see the entire movie . . . if I increase the time, the users of fast machines have to wait around awhile for the movie to disappear.

So, I would like the movie to execute the javaScript when it gets to the last frame.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
March 30, 2010

please don't cross-post.  in fact, ignore your duplicate message in the as1/as2 forum.

on the last frame of your swf, you can call your javascript function using the flash externalinterface class.

March 30, 2010

Sorry about the cross post.  I thought I only selected Action Script 3.  This is my first post and I am new to Flash.

The issue is that I cannot determine how or where to put externalinterface class.  I have clicked around, but not found where to put the code such that it attaches itself to the last frame of any tween.  I clicked on Commands and tried Run Command..., but I'm not sure if putting the command in a file and then clicking OK will do it.

I looked at the Actions dialog, but it says my current selection cannot have actions applied to it.

kglad
Community Expert
Community Expert
March 30, 2010

you don't put the class anywhere.   you just use its methods.  i don't think you even need to import it when using as3:

ExternalInterface.call("yourJSfunction", "any variable(s) you want to send");