从JavaScript触发动作脚本功能(在Flash对象中) [英] Trigger an actionscript function (in a flash object) from javascript

查看:87
本文介绍了从JavaScript触发动作脚本功能(在Flash对象中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Flash(AS2.0)应用程序,其功能需要从html表单链接触发 Flash函数仅运行gotoAndPlay('label name'); 所以我的HTML是
<a href="" id="flashTrigger" />

I have a flash (AS2.0) application with a function that i need to trigger from a html form link The flash function only runs a gotoAndPlay('label name'); So my HTML is
<a href="" id="flashTrigger" />

我的闪光灯功能是

  
function myFunction(){
  gotoAndPlay("myLabel");
}

任何人都知道如何从html链接标记中触发Flash函数,或者从Javascript函数中运行"gotoAndPlay"

Anyone know either how I can fire the flash function from the html link tag, OR run a "gotoAndPlay" from a Javascript function

IV环顾四周,似乎只发现如何从Flash触发javascript函数

Iv looked around and only seem to find how to fire a javascript function from flash

这是我到目前为止的代码-我可能会做一些愚蠢的事情
闪光灯:

Here is the code I have so far - Im prob doing something stupid
Flash:


ExternalInterface.addCallback( "myExternalMethod", this, myFunction );

function myFunction(){
gotoAndPlay("fade");
}

JavaScript

Javascript


function executeFlash()
{
  getObjectById("myFlashID").myExternalMethod(); 
}

function getObjectById(objectIdStr) {
        var r = null;
        var o = document.getElementById(objectIdStr);
        if (o && o.nodeName == "OBJECT") {
            if (typeof o.SetVariable != undefined) {
                r = o;
            }
            else {
                var n = o.getElementsByTagName(OBJECT)[0];
                if (n) {
                    r = n;
                }
            }
        }
        return r;
    }

$(function() {

    $('#WhatDoesmean').click(function(){
        executeFlash();
    });

});

我已将myFlashID设置为以下ID:
初始的对象标签" 和IE仅嵌入标签"

I have set myFlashID to the id of:
initial 'Object tag' and IE only 'embed tag'

目前,我正好将Flash对象定位为目标,这是外部(闪光灯侧)功能无法正常工作的原因 -错误消息,myExternalMethod不是函数

At the moment I am targeting the flash object fine, it's the external (flash side) function which is not working - error message, myExternalMethod is not a function

推荐答案

我已经设法通过使用SWFObject来解决该问题

I have managed to crack the problem by using SWFObject

通过SWFObject.js可以轻松访问Flash对象方法,但是没有它就无法工作.不确定为什么.

Accessign the flash objects method was easy through SWFObject.js, however it just wasnt working without it. Not sure why though.

以上所有建议均适用于SWFObject.js,但如果没有该建议,似乎都无法使用

All the above suggestions work with SWFObject.js, but none seemed to work without it

为大家的建议加油

安迪

这篇关于从JavaScript触发动作脚本功能(在Flash对象中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆