开发者

flash, how to call an external javascript on frame action/change

i have a flash movie with 2 frames. and i would like to call an external javass开发者_运维百科cript function on frame action.

to call it from a button i can use:

on (release) {
getURL("javascript:OpenMe();");
}

but i don't know ho to do it on frame action, maybe on frame load...

any ideas?

Thanks


You can add code directly to a keyframe on the timeline. On your keyframe just put:

getURL("javascript:OpenMe();");

That said, this is not the recommended way to call JavaScript from Flash. You should be using the ExternalInterface class. The same call with ExternalInterface would look like this:

if(ExternalInterface.available) ExternalInterface.call("OpenMe");


The easiest way is to create a movieclip with _visible set to false, and then place that inside as

onLoad = function(){getURL("javascript:OpenMe();");

That way, you can edit the functionality in one place and it will edit both. It also ensure that it happens onLoad and not before (meaning that it will happen after everything on the timeline).

As a side note, ExternalInterface is generally suggested as the preferred way to us JS in AS, especially since it is future compatible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜